Display navigator.geolocation.getCurrentPosition in Baidu Maps

We know that due to the infamous GPS GPS offset problem in China, GPS (WSG-84) map coordinates do not exactly match the coordinate system used by state-approved Chinese maps (GCJ-02).

The question is how to make sure that placing the marker through the Baidu map API in the coordinates reported by navigator.geolocation.getCurrentPosition() will correspond to reality?

Will the GPS chip of a device manufactured or approved for use in China return coordinates that do not correspond to the actual position of the user, instead of which correspond to GJC-02 cards?

Does it matter if the user launches a Chinese navigator (for example, Maxthon or Google Chrome, localized in Chinese), as opposed to a non-Chinese browser, for example. Firefox in English?

Here's a JSBin that checks geolocation and uses the Baidu map coordinate conversion API . Unfortunately, I am not located in China, so I can’t check.

Here is the question:

Does the application above need to convert Baidu coordinates to the coordinates that it receives from navigator.geolocation.getCurrentPosition() in order to correctly show the location on a Baidu map or not? Can someone find a test in China, ideally with a Chinese browser on a Chinese device and with a non-Chinese browser on a non-Chinese device?

+2
javascript google-maps geolocation chinese-locale baidu
source share
1 answer

Umm ... first of all, it looks like they have an API to do just that: raw gps location to baidu gps location . I was not able to find the documentation, but I think that their jsfiddle(?) Can give you an idea of jsfiddle(?) .

both on devices and on the browser. Since Xiaomi phones work fine in the US, so I think the Android system just returns to the normal GPS source location. Also, Chinese browsers using them on an American phone still give me the right position. so I think the browser has nothing to do with the shift.

hope this help.

0
source share

All Articles