Skip Navigation

[Resolved] How would I set a click listener on each marker

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to know how to set a click listener on each Marker.

Solution: You can access the Map Marker objects in JavaScript:

WPViews.view_addon_maps.markers['yourMapID'].

Here's a simple click handler example on a Marker object:
https://developers.google.com/maps/documentation/javascript/examples/event-simple

This support ticket is created 6 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by Christian Cox 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#729188

I have a map with multiple markers, all of them are custom posts I have created. e.g.
hidden link

Each has an address added using the Google Maps API,
hidden link

How would I set a click listener on each marker, which would allow me to get the id of the post associated to that marker and execute some javascript function?

We are trying to show the post Body of each post when the corresponding marker is clicked.

What is the link to your site?
hidden link

#729222
Screen Shot 2018-04-24 at 16.51.41.png

this is a screenshot of the desired output.

#730421

Hi, we don't offer much support for this level of customization, so you'll be mostly on your own here. With that being said, you can access the Map Marker objects in JavaScript at WPViews.view_addon_maps.markers['yourMapID'].
Here's a simple click handler example on a Marker object:
https://developers.google.com/maps/documentation/javascript/examples/event-simple