How to show multiple markers in Google Map API v3?

5

I can not mark multiple points on the map. Could you check if something is wrong with the code?

var map;
var idInfoBoxAberto;
var infoBox = [];
var marker ;
var geocoder;

function initialize() {
    var latlng = new google.maps.LatLng(latitudes, longitudes);

    var options = {
        zoom: 14,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    map = new google.maps.Map(document.getElementById("mapa"), options);
    geocoder = new google.maps.Geocoder();

    for (var i = 0; i < coord.length; i++) {
        marker = new google.maps.Marker({
            position: new google.maps.LatLng(coord[i]),
            map: map,
        });
    }
}

initialize();
    
asked by anonymous 30.04.2015 / 21:50

1 answer

2

Since its array coord a string , the snippet you set the position of each marker is incorrect, since the constructor of the class

30.04.2015 / 22:28