Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I link Google Maps Markers to other elements?
    text
    copied!<p>Using the <a href="http://code.google.com/apis/maps/documentation/reference.html" rel="nofollow noreferrer">google maps</a> (and JavaScript) I have been able to easily display several markers which each have a nice little info window over them.</p> <pre><code>//Create map over USA map = new google.maps.Map2( document.getElementById('map') ); map.setCenter(new GLatLng(38.95940879245423, -100.283203125), 3); //Create point, then marker, and then add to map function create_marker(lat, lng, html) { var marker = new GMarker( new GLatLng(lat,lng)); marker.bindInfoWindow(html); map.addOverlay(marker); } var html = '&lt;div&gt;this is my text&lt;/div&gt;'; create_marker(38.95940879245423, -100.283203125, html); </code></pre> <p>However, I now want to be able to link the "click" of markers to functions which can update other parts of the page as well. For example, I would like to have a sidebar with copies of the marker infowindow content. The same way <a href="http://www.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=frys,+texas&amp;sll=37.0625,-95.677068&amp;sspn=54.22533,79.013672&amp;ie=UTF8&amp;hq=frys,&amp;hnear=Texas&amp;z=7" rel="nofollow noreferrer">google maps shows results</a> on the left and markers on the right. I might even want the click of sidebar content to open a given marker infowindow on the map.</p> <p>The problem is that the <a href="http://code.google.com/apis/maps/documentation/reference.html#GMarker" rel="nofollow noreferrer">GMarker</a> click event only passes the lat/long - and I'm not sure how I can use that to find the matching div or whatever.</p> <p>How do I get a unique id/handle for each marker?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload