I am using Leaflet and I am trying to create a polyline and marker points but it gives opposite lat and long so I have to swap them. Creating a marker is easy because it only has one pair of lat and long but creating a polyline is complicated because has a lot of points.
Below is what I am currently using to swap lat and long for marker points.
var splitObj = objVal.toString().split("],[");
var latlng = splitObj.map(function(x)
{
var couple= (/\d+.\d+, \d+.\d+/g).exec(x).toString();
var splitted = couple.split(", ");
return "["+splitted[1]+","+splitted[0]+"]";
});
latlng.join();
Result:
['[[a, b], [c, d], [e, f]]'] // this is the objVal
expectation:
['[[b,a], [d,c], [f,e]]']
reality:
['[b,a]']