0

I am using the following:

    var SampleMarker = new google.maps.Marker({
        position: new google.maps.LatLng(51.379, -113.53),
        map: map,
        title: "Hello World!"
    }); 

To add a marker to my map, but how would I use the same to say iterate over an array of latlngs? I wish to add multiple markers.

GHC
  • 2,658
  • 5
  • 30
  • 35
TheWebs
  • 12,470
  • 30
  • 107
  • 211

1 Answers1

1

You can simply wrap that in a function and call it in any loop :

function createMarker(latitude, longitude, myTitle){

    new google.maps.Marker({
        position: new google.maps.LatLng(latitude, longitude),
        map: map,
        title: myTitle
    });

}

have fun.

LoicUV
  • 386
  • 5
  • 9