We know that due to the infamous China GPS offset problem, GPS (WSG-84) map coordinates don't correspond exactly to the coordinate system that state-approved Chinese maps use (GCJ-02).
The question is, how does one make sure that placing a marker via the Baidu Maps API at the coordinates reported by navigator.geolocation.getCurrentPosition()
will match reality?
Would the GPS chip of a device manufactured or approved for use in China return coordinates that don't match the actual position of a user, in order to instead match he GJC-02 maps?
Does it matter if the user runs a Chinese navigator (e.g. Maxthon, or Google Chrome localized in Chinese), vs. a non-Chinese browser, e.g. Firefox in English?
Here's a JSBin that tests geolocation and uses the Baidu Maps coordinates conversion API. Unfortunately I'm not located in China so I can't test.
Here's the question:
Does the app above need to run the Baidu coordinates conversion on the coordinates it gets from navigator.geolocation.getCurrentPosition()
in order to show the location correctly on the Baidu Map, or not? Could someone located in China test, ideally with both a Chinese browser on a Chinese-manufactured device, and with a non-Chinese browser on a non-Chinese device?
Umm... first of all, it seems like they have a API to do just that: raw gps location to baidu gps location. I was not able to find the documentation but I think their
jsfiddle(?)
might give you an idea to get started.as of the devices, and browser.. Since Xiaomi phones are working fine in the US, so I guess the android system just returns the normal raw GPS location. Also the Chinese browsers, using them in a US phone still gives me the correct position. so I think the browser has nothing to do with the shift too.
hope this help.