Google Map google.maps.event.trigger not working on V3

I have a map on the site. and I try to start a click on the marker by clicking the link (off the map) on the side of the map.

Here is the code:

<a id="ctl00_ctl00_cphMain_main_rptTouristique_ctl00_lnk" onclick="javascript:google.maps.event.trigger(markerArray[0],'click') ">Le Vieux MontrΓ©al</a> 

Note. markerArray is an array of all the markers on the map.

Note. I am working with API version 3 (current)

+4
source share
2 answers

I am sure that you should trigger the click event from the outside, which means that you are running the function, so you can call the same function to show that the marker is being fired. For instance,

 function callAfterMarker(){ alert("Market Clicked"); } google.maps.event.addListener(marker, 'click', function() { callAfterMarker(); }); <a href="javascript:callAfterMarker();">Address Name</a>"; 

In addition, you have a marker array, and you can decide with which marker your function or position should be calculated and executed. (ie) If you want to pass any marker related information to this function.

Hope this helps!

+1
source

I am not sure what you are, but I believe that you need to configure the click function.

 google.maps.event.addListener(marker, 'click', function() { map.setCenter(marker.position); }); <a href="javascript:google.maps.event.trigger(markerArray[0],'click')">Address Name</a>"; 
+1
source

All Articles