APPinAIR APPinAIR - 7 months ago 11
Javascript Question

AngularJS convert geo coordinates from Lambert 2 to WSG84

Now I have geo coordinates of Lambert 2, like this

X:595833.007,
Y:2418927.985


In order to show this place in the google map, I need the related geo coordinates of WSG84, like this

X:48.7687954,
Y:2.27984782


Is there angularjs library which includes the this function ? Thanks in advance.

Answer

To realize the convertion of coordinates among different geodetic systems, I create this repo, angular-geo-converter. it is quite easy to use.

Add the script dependence of angular-geo-convert.js:

  <script src="angular-geo-converter.js"></script>

Add the module dependence in your root module of your angular application:

  angular.module('app',['geoConverter'])

Call the service in your controller

  angular.module('app').controller('geoCtrl',['geoConverter',function(geoConverter){
    var coordinates = geoConverter.lambert2wgs(595833,2418928);
    var coordinateX = coordinates.latitude;    // result:48.7687954
    var coordinateY = coordinates.longitude;    // result:2.27984782
  }])

PS: The convertion in the answer of manzapanza is not correct.