Why not use the official _cordova-plugin-geolocation_ plugin for Android The latest version of the plugin has removed the Android version of the positioning code, and the location is based on the system browser (chrome kernel).
The same question has been asked, and the author's answer is that it is faster and more accurate than native positioning.
But after testing, it was found that it could not be located at all, and after several investigations, it was found that it was related to what seemed to be a domestic network, and I believe everyone understands the reason, so I omitted a few words.
Baidu Map Positioning Cordova plug-in, supports Android, IOS, ionic 1x 2x can be used
cordova location plugin: cordova-plugin-baidumaplocation GitHub address:https://github.com/aruis/cordova-plugin-baidumaplocation ionic3 example:https://github.com/aruis/testbmap-cordova-ionic3
Test Environment:Huawei Honor 10 mobile phone (Android 8.1), ionic3
No nonsense, let's upload the renderings first:
Use the tutorial
1: Apply for Android and IOS version key, this step is omitted, please refer to the following to apply for Android key:
2: Install the plugin
UninstallPlugin commands:
If only the ANDROID_KEY is filled in, the error will be as follows:
(node:1204) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Variable(s) missing (use: --variable IOS_KEY=value). (node:1204) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 3: How to use
Add the following code under the android node of the project/platform/android/app/build.android file:
in the project\src\app\app.component.tsfile, replace the code as follows:
The error will be reported as follows when running on the web page, in fact, there is no need to worry.Directly package it as an apk and install it on your phone!!
Uncaught (in promise): ReferenceError: cordova is not defined
ReferenceError: cordova is not defined at http://localhost:8100/build/main.js:436:13 at t.invoke (http://localhost:8100/build/polyfills.js:3:14976) at Object.onInvoke (http://localhost:8100/build/vendor.js:5134:33) at t.invoke (http://localhost:8100/build/polyfills.js:3:14916) at r.run (http://localhost:8100/build/polyfills.js:3:10143) at http://localhost:8100/build/polyfills.js:3:20242 at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15660) at Object.onInvokeTask (http://localhost:8100/build/vendor.js:5125:33) at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15581) at r.runTask (http://localhost:8100/build/polyfills.js:3:10834) Package it into an app, install it on the phone, and when you run it for the first time, it will prompt you to need location permissions, click Always Allow, as shown in the figure below:
For specific field content, please refer to:
BDLocation v7.2 for Android:http://wiki.lbsyun.baidu.com/cms/androidloc/doc/v7.2/index.html
BMKUserLocation v3.3.4 for IOS:http://wiki.lbsyun.baidu.com/cms ... 5c5554fe16aca1b4fbf
|