I have following script to add Dynamically Polylines using latlang points which was saved in user previous session. Script is executing without any error but Polylines are not drawing on the map.
var latLonArray = item.points[0];
pointList = [];
for (var i = 0; i < latLonArray.length; i++) {
var item = latLonArray[i];
var pnt = new L.LatLng(item[0], item[1]);
pointList.push(pnt);
}
var firstpolyline = new L.Polyline(pointList, {
color: 'blue',
weight: 3,
opacity: 0.5,
smoothFactor: 1
});
//var polygonObj = simeObj.DrawPolygon(points);
//polygonObj.addTo(mapObject);
//var firstpolyline = new L.Polygon(item.points, item.layer);
firstpolyline.addTo(mapObject);
I have tried with DrawPolygon method also. It is also not drawing polygon on the map.
The issue was solved in the comments, the result:
The problem was that the latlng value was in the lnglat format:
Change from
var pnt = new L.LatLng(item[0], item[1]);
to
var pnt = new L.LatLng(item[1], item[0]);
worked.