Skip to content

inkCrazy/react-native-amap-geolocation

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-amap-geolocation npm version build status

React Native 高德地图定位模块,支持 Android + iOS。

使用

  1. 安装
  2. 获取 Key:
import { PermissionsAndroid } from "react-native"
import { Geolocation } from "react-native-amap-geolocation"

const granted = await PermissionsAndroid.request(
  PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION
);

if (granted === PermissionsAndroid.RESULTS.GRANTED) {
  await Geolocation.init({
    ios: "9bd6c82e77583020a73ef1af59d0c759",
    android: "043b24fe18785f33c491705ffe5b6935"
  })

  Geolocation.setOptions({
    interval: 8000,
    distanceFilter: 20
  })

  Geolocation.addLocationListener(location => console.log(location))
  Geolocation.start()
}

文档

示例

你可以直接下载安装 example.apk,或者按照以下步骤运行项目示例:

yarn

# android
yarn run-android

# ios
cd ios && pod install && cd ..
yarn run-ios

About

React Native geolocation module for Android + iOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 38.2%
  • Objective-C 33.9%
  • JavaScript 17.5%
  • Ruby 10.4%