Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There might be a plug in out there to do what you want, but it's also possible to do without one. I did something like that in one of my projects. </p> <ol> <li>Add event listener to each marker; clicking opens marker list info window</li> <li>The content of the marker list info window contains <code>onclick</code> attributes that will open the marker info window.</li> </ol> <p>My code was tucked away into functions, but it was basically just this:</p> <pre><code>//1) while creating marker, create click listener that opens the marker list google.maps.event.addListener(marker, 'click', function() { markerWindow.close(); markerList.open(map, marker); }); //2) store the content required by the marker's info windows var markers = [ [marker1Reference, "The Stadium"], [maerker2Reference, "The Supermarket"] ]; //3) the function that is called each time a marker is chosen from the marker list function openMarkerInfo(markerIndex) { markerList.close(); markerWindow.setContent(markers[markerIndex][1]); markerWindow.open(map, markers[markerIndex][0]); } //4) info window for the marker list - the content includes JS onclick events that will open each marker info window markerList = new google.maps.InfoWindow({ content: "Choose:&lt;br&gt;&lt;br&gt;&lt;div href='' class='markerLink' onclick='openMarkerInfo(0)'&gt;The Stadium&lt;/div&gt;&lt;br&gt;&lt;div href='' class='markerLink' onclick='openMarkerInfo(1)'&gt;My House&lt;/div&gt;" }); //5) the marker window that will get set each time a marker is clicked in the list markerWindow = new google.maps.InfoWindow(); </code></pre> <p>Hope that helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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