Showing navigator.geolocation.getCurrentPosition in Baidu Maps
Asked Answered
M

1

2

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?

Macswan answered 6/4, 2015 at 11:8 Comment(0)
O
0

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.

Orlandoorlanta answered 6/4, 2015 at 16:54 Comment(2)
Umm... first of all, that is exactly the API I use in my JSfiddle: "uses the Baidu Maps coordinates conversion API". My question is, do I need to run the raw GPS location to Baidu coordinates conversion when plotting a photo on the map, or not?Macswan
I think so. Based on some photos I took in Macau, the answer seems to me yes. BaiduAPI(photosGPSInfo) returns the real location of this photo.Orlandoorlanta

© 2022 - 2024 — McMap. All rights reserved.