how to add a simple polylines to Map Api gmaps v3?

1

I can not see the line on the map, the code is apparently correct, it does not break on any line, when I see it on the console.

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

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

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

        if (coord.length > 1) {
            for (var i = 0; i < coord.length; i++) {
                var location = coord[i].split(",");

                pontos[i] = new google.maps.LatLng(location[0], location[1]);

            }

            var flightPath = new google.maps.Polyline({
                path: pontos,
                strokeColor: '#FF0000',
                strokeOpacity: 1.0,
                strokeWeight: 3,
                map: map,
            });

            flightPath.setMap(map);
        }
    }

    initialize();
    
asked by anonymous 04.05.2015 / 18:25

1 answer

1
   var flightPath = new google.maps.Polyline({
            path: pontos,
            strokeColor: '#FF0000',
            strokeOpacity: 1.0,
            strokeWeight: 3,
            map: map
        });

You do not need the comma in the last parameter.

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

The div of your map is actually called "map", if you named it ok, but often it is "map-canvas" or "map", as in the example, if you changed ok! >

I think it's just the comma at the end of the flightPath parameters.

    
19.05.2015 / 16:01