Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>oms.addListener()</code> does not act the same way as <code>google.maps.event.addListener()</code>. So I somehow made it to work by using the original <code>google.maps.event.addListener()</code> instead of <code>oms.addListener()</code> inside a <code>for</code> loop. Like so:</p> <pre><code>var infoWindows = []; function closeInfoWindows(){ var i = infoWindows.length; while(i--){ infoWindows[i].close(); } } function newMarker(map, response, oms){ var loc = new google.maps.LatLng(response.latlong[0], response.latlong[1]); var marker = new google.maps.Marker({ position: loc, title: response.title }); oms.addMarker(marker); var WindowOptions = { content:'some desc...'}; var InfoWindow = new google.maps.InfoWindow(WindowOptions); infoWindows.push(InfoWindow); google.maps.event.addListener(marker, 'click', function() { closeInfoWindows(); InfoWindow.open(carte, marker); // or this instead of marker }); return marker; } for (var i = 0 ; i &lt; response.length; i++) { markers.push(newMarker(map, response[i], oms)); }; </code></pre> <p><strong>Extra credit to:</strong> <a href="https://stackoverflow.com/users/1210329/geocodezip" title="geocodezip">geocodezip</a> and <a href="https://stackoverflow.com/questions/3711700/all-infowindows-have-same-data">All infowindows have same data</a></p> <p>A working example could be found here (my app): <a href="http://concert-dacote.com/m?lat=48.856614&amp;lng=2.3522219000000177&amp;range=10&amp;artist=" rel="nofollow noreferrer">concert-dacote.com</a></p>
    singulars
    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. 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