Coder Social home page Coder Social logo

com.kit.cordova.amaplocation's Introduction

com.kit.cordova.amaplocation

使用高德Android定位SDK进行定位,以解决webapp中定位不准的问题

安装

cordova plugin add https://github.com/namedjw/com.kit.cordova.amaplocation.git --variable KEY=您申请的高德地图androidkey --save ps:此插件android定位功能使用高德定位,ios定位功能使用苹果系统自带的定位功能,所以只需要配置android key,不需要配置ios key

配置

ionic3调用方法

import {Injectable} from '@angular/core';
declare var LocationPlugin;

@Injectable()
export class NativeService {
  constructor() { }
  /**
   * 获得用户当前坐标/坐标系为火星坐标系
   * @return {Promise<any>}
   */
  getUserLocation(): Promise<any> {
    return new Promise((resolve) => {
        LocationPlugin.getLocation(data => {
          resolve({'lng': data.longitude, 'lat': data.latitude});
        }, msg => {
          alert(msg.indexOf('缺少定位权限') == -1 ? ('错误消息:' + msg) : '缺少定位权限,请在手机设置中开启');
        });
    });
  }
}

com.kit.cordova.amaplocation's People

Contributors

xiaosan666 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.