This plugin uses the location function provided by Baidu Map to locate the mobile phone on the Android version.
Why is there no iOS version?
Because the iOS version has the official locator plugin cordova-plugin-geolocation can be used.
Please refer to: cordova-plugin-geolocation
Why not use the official Cordova-plugin-geolocation plugin for the Android version
The latest version of the plugin has been removed from the Android version of the targeted code, instead based on the system browser (Chrome core) to locate.
Why do this, and others ask the same question, the author's answer is that this is faster and more accurate than the native location.
But after testing, found at all unable to locate, after several investigations found with the seemingly domestic network has a relationship, the reason I believe we all understand, this has omitted a few words ....
This plugin was born.
Version
Based on the Baidu map of the Android version of the Positioning SDK (v5.3)
One, apply for key
Please refer to: Application key Android Location SDK
Second, install the plug-in
Ionic plugin add https://github.com/mrwutong/cordova-qdc-baidu-location--variable api_key= "" * * Note: The api_key here is from the first step, Without left and right angle brackets * *
Third, how to use
To locate Baidu_location.getcurrentposition (Successcallback, failedcallback);
Get location information, return JSON format string data:
{ Latitude: latitude, lontitude: Longitude, ...}
If you want to return a JSON object we can modify the code inside the plugin to find baidulocation.javapluginresult pluginresult = new Pluginresult ( PluginResult.Status.OK, sb.tostring ()); Pluginresult Pluginresult = new Pluginresult (PluginResult.Status.OK, JSON); Return data
For specific fields, please refer to: bdlocation
Four, see which plugins are currently installed
Cordova Plugin ls
Five. Remove plugins
Cordova Baidu Map to locate the Android version plugin