Does the Google Maps coordinate map in the same place on Baidu maps?

I am implementing a map in Baidu Maps (China primary map service) using the latitude and longitude originating from Google Maps. I found that my locations (mostly around Shanghai) were consistently "off" for about a kilometer, though!

Performing linear adjustment, Baidu places are displayed approximately (+ - several meters) in the right place:

//Declaring my Baidu map marker properties ... lat : gm_location.lat + 0.00575, lng : gm_location.lng + 0.00668, ... 

Although this will be done for my specific needs, I do not like these magic numbers. Does anyone have an understanding of where this bias comes from?

+2
javascript google-maps
source share
3 answers

Which Google Maps are you using, google.com/map or google.cn/map? Satellite or street view? In all cases, the answer is no, the coordinates will not correspond to the Baidu Map POI, but for several other reasons.

Firstly, since Baidu does not offer any useful maps outside of China , let it focus on the issue.

Is Google Maps in China consistent in the same place on Baidu maps?

The answer is no. Baidu Maps uses its own BD-09 coordinate system , and Google Maps uses either the Chinese GCJ-02 (for street maps on google.com/maps or .cn) or WGS-84 for satellite imagery on google.com satellite maps.

GPS coordinates (WGS-84) and Google Street Map coordinates (GCJ-02) do not map to the same location on Baidu maps, as this fragment demonstrates (I did not include the fragment in the answer because it does not work because of that as SO includes scripts, but you can see the code in this other answer I gave ).

enter image description here

Using linear correction around Shanghai may work, but the values โ€‹โ€‹will vary for other regions of China.

How to compensate for bias

The official method of converting Google coordinates to Baidu map coordinates is to use the Baidu map API for this.

There are two versions of the API:

Take the coordinates of the Google Street Map (GCJ-02) of the monument to the heroes of people in Shanghai and convert them to the coordinates of Baidu maps:

 curl "http://api.map.baidu.com/ag/coord/convert?from=2&to=4&x=121.4914&y=31.2423" 

displays

 {"error":0,"x":"MTIxLjQ5Nzk5OTg3MzM4","y":"MzEuMjQ3OTc1ODQwMTk2"} 

The coordinates are base64 encoded and decoded to

 121.49799987338, 31.247975840196 

If map.baidu.com allowed you to enter lat / lon coordinates, you will land on the Papelรฉ Heroes Monument .

The Baidu API only offers conversion to BD-09.

Conversion can also be performed offline, and formulas can be found on Chinese blogs . Conversion between GCJ-02, WGS-84 and B-09 can be done using libraries such as geoChina or eviltransform .

+9
source share

Companies in China are legally obligated not to export map data without bias in order to mask foreign companies. See https://help.openstreetmap.org/questions/37560/map-offset-in-china for more details.

The coordinates you get from maps.google.com are probably wrong, while those at baidu are probably true.

+1
source share

The Baidu Map API has a service for translating Google Maps coordinates to Baidu map coordinates, but I think this is accurate for locations within China. somewhere else doesn't work

Take a look at the official demo

http://developer.baidu.com/map/jsdemo.htm#a5_1

But be careful, there is a big delay before it returns your translated coordinates.

 var x = 116.32715863448607; var y = 39.990912172420714; var ggPoint = new BMap.Point(x,y); // step 1 - create a Baidu map point from Google Maps coordinate translateCallback = function (data){ if(data.status === 0) { var marker = new BMap.Marker(data.points[0]); // step 3 - u get the offset coordinate here bm.addOverlay(marker); bm.setCenter(data.points[0]); } } setTimeout(function(){ var convertor = new BMap.Convertor(); var pointArr = []; pointArr.push(ggPoint); convertor.translate(pointArr, 3, 5, translateCallback); // step 2 - pass the point as an array to the translate service }, 1000); 
+1
source share

All Articles