Skip Navigation

[Résolu] How would I set a click listener on each marker

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 Il y a 5 années et 12 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 réponses, has 2 voix.

Last updated by Christian Cox Il y a 5 années et 12 mois.

Assisted by: Christian Cox.

Auteur
Publications
#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

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.