Showing navigator.geolocation.getCurrentPosition in Baidu Maps

时光怂恿深爱的人放手 提交于 2019-12-10 11:07:36

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/29470064/showing-navigator-geolocation-getcurrentposition-in-baidu-maps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!