• Resolved castria

    (@castria)


    I have my locations page set to show a list of locations and a map with markers for all off these locations.

    I’d like it so that when a marker is clicked, I can cause that to trigger something off-map (in this case I’d like it to highlight the container of the relevant location from the list via JS).

    Looking here: https://developers.google.com/maps/documentation/javascript/events I can see how that is done but it looks like I’d need to directly edit event-manager.js to do so. Obviously this would break when updating the plugin. Is there a way I can define what happens on clicking a marker in a separate JS file of my own?

    ...
    marker.addListener("click", () => {
      console.log('success');
    });

    Doing something like this in my efforts so far show problems with “marker” being undefined since it’s outside of the correct scope.

    • This topic was modified 4 years, 2 months ago by castria.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter castria

    (@castria)

    I tried using the em_maps_locations_hook in a separate file but i get an error.

    jQuery(document).bind('em_maps_locations_hook', function( e, map, infowindow, marker ) {
      google.maps.event.addListenerOnce(marker, 'click', function(event) {
        console.log('success');
      });
    });

    “Uncaught TypeError: a is undefined”

    Thread Starter castria

    (@castria)

    I tried using the em_maps_locations_hook in a separate file but i get an error.

    jQuery(document).bind('em_maps_locations_hook', function( e, map, infowindow, marker ) {
      google.maps.event.addListener(marker, 'click', function(event) {
        console.log('success');
      });
    });

    “Uncaught TypeError: a is undefined”

    Plugin Support angelo_nwl

    (@angelo_nwl)

    Unfortunately, we don’t have a similar snippet with addlistener but maybe this snippet can help you out – https://pastebin.com/zs7PP25h

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I trigger action by a map marker click without editing events-manager.js’ is closed to new replies.