Google maps: polyline from array

I have a little problem and I spent hours to find a solution.

I have an array, full of coordinates and entries. The thing is, I want to get a polyline which connects all the point coordinates in the array.
Placing markers and infowindows are fine but I can’t get the polyline.

I need to go through the array by a loop because I want to use the same way for other coordinates again.

Can someone help me? Here is the code:

var places = [
['New Delhi', 28.6139587,77.208684],
['Amritsar', 31.643628, 74.859624],
['Srinagar', 34.09, 74.79],
['Kargil', 34.55, 76.133333],
['Alchi', 34.2334, 77.1625],
['Leh', 34.145397, 77.567614]

for (c = 0; c < places.length; c++){
    var coords = new google.maps.LatLng(places[c][1], places[c][2])


var Itinerary = new google.maps.Polyline({
    path: poly,
    geodesic: true,
    strokeColor: '#ffd500',
    strokeOpacity: 1.0,
    strokeWeight: 5


Source: javascript

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.