Navigation überspringen

[Gelöst] How would I set a click listener on each marker

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

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 vor 6 Jahren, 9 Monaten. 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)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Christian Cox vor 6 Jahren, 9 Monaten.

Assistiert von: Christian Cox.

Author
Artikel
#729188

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

Each has an address added using the Google Maps API,
versteckter 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?
versteckter 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