Google Maps and GeoJSon: latitude and longitude co

2019-08-04 02:40发布

问题:

I'm using Google Maps API to visualize some label on the map using google.maps.Polygon. I used this converter http://converter.mygeodata.eu/ to convert them in a GeoJSon format, but latitude and longitude coordinates where mistaken.

They should be centered in Florence, Italy, but actually i get this:

 1680508.8375
 4847672.484

I tried tho divide them by 10000 and i got:

 16.805088375
 48.47672484

wich alow me to show some results, but that was not the results I was looking for (I get them displayed in Austria instead of Florence)

Surfing the net I found this https://groups.google.com/forum/?fromgroups#!topic/d3-js/H0zE7slqV0g that describe my problem and find a solution using d3.

Is there any way to do that just with google maps API and/or using some conversion?

Thanks

回答1:

Ok seems that I found what the problem is. There are many different way to locate a point in a map. Google Maps uses a WGS84 encoding, but i got the data in EPSG:3003 encoding. So they didn't match.

I was able to find a js library that makes all the conversion you need.

http://trac.osgeo.org/proj4js/