This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

cordova-amap-locate

1.1.6 • Public • Published

cordova-amap-locate

npm npm

Install AMap SDK Plugin

// Cordova
cordova plugin add cordova-amap-locate --variable android_key={KEY} --variable ios_key={KEY}
// Ionic
ionic cordova plugin add cordova-amap-locate --variable android_key={KEY} --variable ios_key={KEY}

In order to prevent error, at present you need to set the variable information of both Android and iOS.

Pay attention to IOS platform

Ios is not perfect, you need to continue to set the configuration in Xcode, but this problem will be resolved later

The plug-in relies on cordova-plugin-add-swift-support and cordova-plugin-cocoapods-support, so it needs to be installed in the project and configured according to the instructions.

cordova plugin add cordova-plugin-add-swift-support --save 
cordova plugin add cordova-plugin-cocoapod-support --save

Modify the project config.xml

<platform name="ios">
    ...
    <preference name="deployment-target" value="9.0" />
    <preference name="pods_use_frameworks" value="true" />
    <preference name="UseSwiftLanguageVersion" value="4" />
 
    <pod name="RxSwift" />
    <pod name="RxCocoa" />
    <pod name="AMap3DMap" />
    <pod name="AMapLocation" />
    ...
</platform>

Configuring Xcode

- First of all

check Project Signing, if this isn't configuration, please configure the termId.

- Second part

check Project and Pods Swift Lanaguage Version, if it is Unspecified, you must set a swift version. If you set the version to 4.0, you can change the Project Format to Xcode 8.0.

- Third part

check Project Objective-C Bridging Header,if it is normal, please add these to Bridging-Header.h.

#import <AMapFoundationKit/AMapFoundationKit.h>
#import <AMapLocationKit/AMapLocationKit.h>

- Last

  • Background Modes set On
  • selected Location updates

Used in Cordova

cordova.plugins.locate.getCurrentPosition(function (latlng) {
    console.log(latlng);
});
// output: [lat:double,lng:double]

Used in Ionic

Modify the project app.module.ts

import {AMapLocate} from 'cordova-amap-locate/ionic-native';
 
@NgModule({
  ...
  providers[
    ...
    AMapLocate,
    ...
  ]
})

Use Native

import {AMapLocate} from 'cordova-amap-locate/ionic-native';
 
export class MyApp {
    constructor(platform: Platform,
                amapLocate: AMapLocate) {
        platform.ready().then(() => {
            amapLocate.getCurrentPosition().then(lnglat => {
                alert(JSON.stringify(lnglat))
            });
        });
    }
}

Package Sidebar

Install

npm i cordova-amap-locate

Weekly Downloads

1

Version

1.1.6

License

MIT

Unpacked Size

19.5 kB

Total Files

13

Last publish

Collaborators

  • -kain