ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

高德地图定位(react-native-amap-geolocation)

2020-12-11 12:01:11  阅读:520  来源: 互联网

标签:keystore geolocation node react amap native


高德地图定位(react-native-amap-geolocation)

定位地址: react-native-amap-geolocation

安装

npm install --save react-native-amap-geolocation

android

react-native link react-native-amap-geolocation

ios

在ios目录下新建Podfile

platform :ios, '8.0'

# The target name is most likely the name of your project.
target 'Your Target' do

  # Your 'node_modules' directory is probably in the root of your project,
  # but if not, adjust the `:path` accordingly
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge', # Include this for RN >= 0.47
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket', # Needed for debugging
    'RCTAnimation', # Needed for FlatList and animations running on native UI thread
    # Add any other subspecs you want to use in your project
  ]
  # Explicitly include Yoga if you are using RN >= 0.42.0
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  # Third party deps podspec link
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  pod 'react-native-amap-geolocation', path: '../node_modules/react-native-amap-geolocation/lib/ios'
end
pod install

key

android

https://lbs.amap.com/api/android-location-sdk/guide/create-project/get-key

发布版keystore 生成方法

keystore参数文档

测试版 keystore 自动生成

keystore 存放地址

路径:项目\android\app

查询keystore 的SHA1值

进入当前文件夹中的 cmd

发布版 keystore

keytool -v -list -keystore my-release-key.keystore

一定记住密钥库口令

测试版 keystore

keytool -v -list -keystore debug.keystore

密码:android

返回 SHA1值 例图如上

配置AndroidManifest.xml

android 配置

ios

需要填写 Bundle Identifier

img

调用

import { Geolocation } from "react-native-amap-geolocation";
const geolocationInit = async () => {
  await Geolocation.init({
    ios: "key",
    android: "key"
  });

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

  Geolocation.addLocationListener(location => {
    console.log(location);
  });
}

geolocationInit();

Geolocation.start();   //开始定位
Geolocation.stop();   //获取到定位后需要手动关闭,持续定位ios审核不过
Geolocation.getLastLocation();   //获取最后一次定位的位置

标签:keystore,geolocation,node,react,amap,native
来源: https://blog.csdn.net/weixin_44666116/article/details/111032592

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有