dpa99c / phonegap-launch-navigator

Phonegap/Cordova plugin which launches native route navigation apps for Android, iOS and Windows
369 stars 131 forks source link

Inconsistent coordinate system #186

Open bylh opened 6 years ago

bylh commented 6 years ago

Hi, I found a problem of the coordinate system when using the plugin, I pass standard latitude and longitude coordinates, but there is a certain offset in the position displayed on the gaode maps(amap) and apple maps, this is mainly due to gaode maps and apple maps in china using the GCJ-02 system coordinates, not the WGS84 system coordinates,for gaode maps we can pass a default parameter & dev=1 for automatic conversion itself, "https://lbs.amap.com/api/amap-mobile/guide/ios/route", there is no corresponding parameter setting is found for apple maps, maybe need to convert outside. Of course, these coordinates can be converted externally. A better way is to unify the interface and do the internal conversion as much as possible . Is it possible? Thanks.

dpa99c commented 6 years ago

The plugin would have to know that the input address/coordinates refer to China in order to know whether to convert WGS84 coordinates to GCJ-02. So it would need some geofencing data to outline China and know that the coordinates need translating. Also, if the input is an address and the app being launched doesn't support address input (such as Amap), then the plugin will attempt to geocode the address to coordinates using a native geocoding service. The plugin would need to know if the returned coordinates are in WGS84 or have already been adjusted to GCJ-02.

I also presume that this is dependent on which app is being launched? Does every app supported by this plugin default to using GCJ-02 when the coordinates refer to China? If not, the plugin would need to maintain a list of which apps do and don't use GCJ-02.

So I think there would be quite a bit of complexity for the plugin to automatically handle the translation of coordinates between coordinate systems specifically for China. However, if you're willing to implement it, I'm prepared to accept a Pull Request which does so 😃