Open source PHP function for converting UTM coordinates to latitude and longitude?

后端 未结 8 1669
别那么骄傲
别那么骄傲 2020-12-16 04:53

I\'m making a PHP application involving Google Maps. Maps only accepts lat&lng pairs, and the data I want to display comes only with UTM style coordinat

8条回答
  •  旧巷少年郎
    2020-12-16 05:22

    I know it's late to answer this question but since I couldn't use any of the above codes, I wrote my own version which is actually very easy to use. This is the address: https://github.com/maroofi/coordinates To convert UTM to LatLong:

    utm2ll(729286.9550018794,4021544.8279992654,40,true); 
    

    output:

    {"success":true,"attr":{"lat":36.311665575271,"lon":59.553858137274}} 
    

    To convert LatLong to UTM:

    ll2utm(36.311665575277935,59.55385813725379);
    

    output:

    {"success":true,"attr":{"x":729286.95500188,"y":4021544.8279993,"zone":40,"aboveEquator":true}} 
    

    Hope it helps.

提交回复
热议问题