Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps Api v3 - Multiple Info Windows with custom content
    primarykey
    data
    text
    <p>I have finally managed to add multiple markers with custom icons to my Googlemap.</p> <p><strong>The next step would be to add an individual Infowindow for each marker.</strong> Unfortunatelly i cant figure out how.</p> <p>Here is my script so far:</p> <pre><code>&lt;script type="text/javascript"&gt; var offender_locations = [ ["10010", "http://localhost/safenation/img/map_offender_icon.png"], ["10001", "http://localhost/safenation/img/map_visitor_icon.png"] ]; var myOptions = {zoom: 10,center: latlng,mapTypeId: google.maps.MapTypeId.ROADMAP}; var map = new google.maps.Map(document.getElementById("elementid"), myOptions); var latlng = new google.maps.LatLng(0, 0); var marker; var i; for (i = 0; i &lt; offender_locations.length; i++) { var infowindow = new google.maps.InfoWindow(); var geocoder_map = new google.maps.Geocoder(); var address = offender_locations[i][0]; var icon = offender_locations[i][1]; geocoder_map.geocode({'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: map.getCenter(), icon: icon }); google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(offender_locations[i][1]); infowindow.open(map, marker); } })(marker, i)); } else {alert("The requested offender is not mappable !")};}); } &lt;/script&gt; </code></pre> <p>I think there now is a problem with the loop. When i try:</p> <pre><code>var icon = offender_locations[1][1]; </code></pre> <p>all icons are "map_offender_icon.png"</p> <p>When I use :</p> <pre><code>var icon = offender_locations[i][1]; </code></pre> <p>nothing changes and all icons are still "map_offender_icon.png"</p> <p>It seems the var offender_locations[i][1]; is not changing accordingly. The var offender_locations[i][0]; changes accordingly.</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.
 

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