Cordova Baidu Map to locate the Android version plugin

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.