Rearranging order of each element in array

Viewed 47

My application reads every linestring in a GeoJSON file with JQuery :

$.getJSON("testROUTES.geojson", function (dat) {

    $.each(dat.features, function (key, val) {

      var line = val.geometry.coordinates
      console.log(line)
      console.log(line[0])

    });
});

However the order of the lat/lon coordinates needs to be switched. For example, the above code returns: enter image description here

How would one rearrange the coordinates in var line so that the coordinates would read [45,-122] instead of [-122,45] with Jquery?

3 Answers
Related