Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to show 2 markers on a Google Map?
    primarykey
    data
    text
    <p>How do I get multiple markers on a Google Map, using Javascript API v3? Below, when my code adds the second marker it's <em>removing</em> the first one.</p> <pre><code>var locations = { "1" : { "name": "location1", "address": "10000 N Scottsdale Rd", "city": "Scottsdale", "state": "AZ", "zipcode": "85253" }, "2" : { "name": "location2", "address": "15440 N 71st Street", "city": "Scottsdale", "state": "AZ", "zipcode": "85254" } } var geocoder = new google.maps.Geocoder(); for (item in locations) { var loc = locations[item].address + ", " + locations[item].city + " " + locations[item].state + " " + locations[item].zipcode; geocoder.geocode( { 'address': loc}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { var options = { zoom: 10, center: results[0].geometry.location, mapTypeId: google.maps.MapTypeId.ROADMAP, disableDefaultUI: true, zoomControl: true } if (map) { new google.maps.Marker({ map: map, position: results[0].geometry.location, title: locations[item].name }); } else { var map = new google.maps.Map(document.getElementById("map"), options); new google.maps.Marker({ map: map, position: results[0].geometry.location, title: locations[item].name }); } var infowindow = new google.maps.InfoWindow({ content: "test"}); } else { // if map lookup fails, display a map of phoenix var phoenix = new google.maps.LatLng(33.4483771,-112.07403729999999); var options = { zoom: 11, center: phoenix, mapTypeId: google.maps.MapTypeId.ROADMAP, disableDefaultUI: true, zoomControl: true } map = new google.maps.Map(document.getElementById("map"), options); } }); } </code></pre>
    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. 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