0

I'm having some trouble adding more than 1 marker to my map. If I want to display one marker, it works fine. Here is what I have:

<script src="https://maps.googleapis.com/maps/api/js"></script>
<script>
 function initialize() {
        var map_canvas = document.getElementById('map_canvas');
        var map_options = {
          center: new google.maps.LatLng(42.3581, -71.0636),
          zoom: 13,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        var map = new google.maps.Map(map_canvas, map_options)

        //this section works perfectly and displays the marker
        var image = 'http://media.tumblr.com/tumblr_m3w1gbnPK21r017k2.png'; //cappy's pizza
        var myLatLng = new google.maps.LatLng(42.343744, -71.089640);
        var placeMarker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: image

       //but when I add this, the map doesn't show up at all
        var image2 = 'http://icons.iconarchive.com/icons/mad-science/food-on-a-stick/32/kabob-icon.png'; //ali baba
        var myLatLng2 = new google.maps.LatLng(42.343613, -71.064816);
        var placeMarker2 = new google.maps.Marker({
        position: myLatLng2,
        map: map,
        icon: image2


  });
      }
      google.maps.event.addDomListener(window, 'load', initialize);



</script>

Edited by munchlaxxx

2
Contributors
1
Reply
15
Views
3 Years
Discussion Span
Last Post by iConqueror
1

You are not closing off your google.maps.Marker code block for the first marker:

var placeMarker = new google.maps.Marker
({
        position: myLatLng,
        map: map,
        icon: image
});
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.