22----
33
44[ ![ NPM Version] ( https://img.shields.io/npm/v/@uiw/react-native-amap-geolocation.svg )] ( https://npmjs.org/package/@uiw/react-native-amap-geolocation )
5+ ![ SDK-6.2.0] ( https://shields.io/badge/SDK-6.2.0-green?logo=android&style=flat )
6+ ![ AMapLocation-2.9.0] ( https://shields.io/badge/AMapLocation-2.9.0-green?logo=apple&style=flat )
57![ David] ( https://img.shields.io/david/peer/uiwjs/react-native-amap-geolocation )
68
79React Native 高德地图定位模块,支持 Android/iOS。提供尽可能完善的原生接口,同时提供符合 Web 标准的 Geolocation API 以及 [ 完整的接口文档] ( https://uiwjs.github.io/react-native-amap-geolocation/ ) 。
@@ -81,6 +83,44 @@ nehelper sent invalid result code [1] for Wi-Fi information request
8183
8284</details >
8385
86+ <details >
87+ <summary >Android:获取 apikey 失败 errorCode : 10001</summary >
88+
89+ ``` bash
90+ 原因:*** 确保调用SDK任何接口前先调用更新隐私合规updatePrivacyShow、updatePrivacyAgree两个接口并且参数值都为true,若未正确设置有崩溃风险***
91+ 使用loc SDK 功能使用前请确保已经正确设置apiKey,如有疑问请在高德开放平台官网中搜索【INVALID_USER_KEY】相关内容进行解决。
92+ ```
93+
94+ 解决方法:重新申请 ` apikey `
95+
96+ </details >
97+
98+
99+ <details >
100+ <summary >Android:new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method</summary >
101+
102+ ``` bash
103+ WARN ` new NativeEventEmitter ()` was called with a non-null argument without the required ` addListener` method.
104+ WARN ` new NativeEventEmitter ()` was called with a non-null argument without the required ` removeListeners` method.
105+ ` ` `
106+
107+ 解决方法:重新申请 ` apikey`
108+
109+ < /details>
110+
111+ < details>
112+ < summary> Android:请在高德开放平台官网中搜索" SERVICE_NOT_EXIST" 相关内容进行解决< /summary>
113+
114+ ` ` ` bash
115+ 请在高德开放平台官网中搜索" SERVICE_NOT_EXIST" 相关内容进行解决
116+ ```
117+
118+ 解决方法:[ 重新申请 ` apikey ` ] ( https://lbs.amap.com/cooperation/technical_advisory/?tab=4 )
119+
120+ ![ ] ( ./imgs/SERVICE_NOT_EXIST.png )
121+
122+ </details >
123+
84124## 安装依赖
85125
86126``` bash
@@ -92,9 +132,15 @@ $ cd ios && pod install
92132## 基本用法
93133
94134``` javascript
135+ import { PermissionsAndroid } from " react-native" ;
95136import { Platform } from ' react-native' ;
96137import AMapGeolocation from ' @uiw/react-native-amap-geolocation' ;
97138
139+ await PermissionsAndroid .requestMultiple ([
140+ PermissionsAndroid .PERMISSIONS .ACCESS_FINE_LOCATION ,
141+ PermissionsAndroid .PERMISSIONS .ACCESS_COARSE_LOCATION ,
142+ ]);
143+
98144let apiKey = ' ' ;
99145
100146if (Platform .OS === ' ios' ) {
@@ -152,8 +198,11 @@ const listener = AMapGeolocation.addLocationListener((location) => {
152198 this .setState ({
153199 location: JSON .stringify (location, null , 2 ),
154200 });
155- listener .remove ();
156201});
202+ // 移除监听事件
203+ listener .remove ();
204+ // 开启监听
205+ AMapGeolocation .start ();
157206```
158207
159208## 逆地理编码
@@ -511,7 +560,7 @@ nehelper sent invalid result code [1] for Wi-Fi information request
511560当前工程基于 [ @brodybits/create-react-native-module ] ( https://github.com/brodybits/create-react-native-module ) 初始化。
512561
513562``` bash
514- npx create-react-native-module --package-identifier com.uiwjs.react .geolocation --object-class-name RNAMapGeolocation --generate-example AMapGeolocation --example-react-native-version 0.63.0 --module-name @uiw/react-native-amap-geolocation --github-account uiwjs --author-name " Kenny Wong" --author-email " wowohoo@qq.com"
563+ npx create-react-native-module --package-identifier com.uiwjs.example .geolocation --object-class-name RNAMapGeolocation --generate-example AMapGeolocation --example-react-native-version 0.63.0 --module-name @uiw/react-native-amap-geolocation --github-account uiwjs --author-name " Kenny Wong" --author-email " wowohoo@qq.com"
515564```
516565
517566## 开发
0 commit comments