I am using the Google Maps API v3 anf jQuery 1.11.0.
I have a google map in the following div -
<div id="googleMap" class="map_div"></div>
The map has 4 markers, and this click event is added this way in JS -
google.maps.event.addListener(marker, 'click', (function(marker, i) //Adding Click Function { return function() { //Add Your Customized Click Code Here alert(locations[i][3]); //End Add Your Customized Click Code Here } })(marker, i));
Now I have a button in another part of the html ( external map ), like this -
<button id="3">Click Me</button>
Now I want to add an on click event that triggers a map marker click event with index 3.
So, I have JavaScript in HTML like this -
<script> $(document).ready(function() { $("#3").click(function(){ google.maps.event.trigger(markers[3], 'click'); }); }); </script>
But it does not work. I think he cannot select a marker using jQuery. Since I previously selected a map using jQuery, for example:
google.maps.event.trigger($("#googleMap")[0], 'resize');
To resize the map.
So can anyone help me have a google map marker script selector in jQuery .
Thanks in advance for your help.
javascript jquery html google-maps google-maps-api-3
Abrar jahin
source share