To create the Polyline
, you need to add the array of coordinates inside the loop, and then outside of the loop you can add a single mapobject
to the Display
e.g.:
var coords = [],
salesmanTrackPoints;
// Loop to add all the coordinates to an array
$.each(data, function (i, val) {
coords.push(parseFloat(val.latitude));
coords.push(parseFloat(val.longitude));
});
// Now create the Polyline
salesmanTrackPoints = new nokia.maps.map.Polyline(coords, {
pen: {
strokeColor: "#22CA",
lineWidth: 5
},
arrows: true
});
map.objects.add(salesmanTrackPoints);
Of course this may need to be altered depending upon the structure of your data. It is important to note that Polyline
can take an Array
of Coordinates
or an Array
of Numbers
(as individual lat, longs) as you can see from the API Documentation.