tnrn-amap-location
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

tnrn-amap-location

npm npm npm npm

使用

  1. 安装

    yarn add tnrn-amap-location
    

    iOS 需要这样设置:

    Build Setting -> Framework Search Paths 中添加 $(SRCROOT)/../node_modules/tnrn-amap-location/ios/Framework

    Build Phases -> Link Binary WithLibraries 中添加 ExternalAccessory.framework

  2. 获取 Key:

import { PermissionsAndroid } from "react-native"
import { Geolocation } from "tnrn-amap-location"

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()
}

最后:

由于 react-native-amap-geolocation 有些在使用上面的问题,因此 fork 了这份代码

issue:iOS 定位多次回调

Package Sidebar

Install

npm i tnrn-amap-location

Weekly Downloads

2

Version

1.0.4

License

MIT

Unpacked Size

11.2 MB

Total Files

36

Last publish

Collaborators

  • winterw