user2983355
user2983355

Reputation: 43

Polylines in google map V3

Hi mates iam using poly lines in in my google map but iam facing some problem while using it.

flightPlanCoordinates = [new google.maps.LatLng(30.265944, 78.0558291),new google.maps.LatLng(30.75, 76.78)];
var flightPath = new google.maps.Polyline({
                path: flightPlanCoordinates,
                geodesic: true,
                strokeColor: '#FF0000',
                strokeOpacity: 1.0,
                strokeWeight: 2
            });

            flightPath.setMap(map);

This piece of code works perfectly but when i sightly change this code in this way it wont set line between two coordinates

for (i = 0; i < size; i++) {
flightPlanCoordinates[i] = [new google.maps.LatLng(msg.coordinates[i].latitude, msg.coordinates[i].longitude)];
}
var flightPath = new google.maps.Polyline({
                path: flightPlanCoordinates,
                geodesic: true,
                strokeColor: '#FF0000',
                strokeOpacity: 1.0,
                strokeWeight: 2
            });

            flightPath.setMap(map);

Please help me.. thnks in advance

Upvotes: 0

Views: 99

Answers (1)

Subodh Bisht
Subodh Bisht

Reputation: 899

for (i = 0; i < size; i++) {
flightPlanCoordinates[i] = [new google.maps.LatLng(msg.coordinates[i].latitude, msg.coordinates[i].longitude)];
}

Just change your this one code from the code given below

for (i = 0; i < size; i++) {
flightPlanCoordinates[i] = new google.maps.LatLng(msg.coordinates[i].latitude, msg.coordinates[i].longitude);
}

And let me whether it works or not

Upvotes: 1

Related Questions