Commit 7a90d593c12abe5b0e25eab582381910780e7ea0
1 parent
7b0083cb
定位和地址逆解析bug修复
Showing
3 changed files
with
16 additions
and
7 deletions
lib/android/src/main/java/cn/feewee/amap3d/modules/AMapGeolocationModule.java
@@ -186,14 +186,18 @@ public class AMapGeolocationModule extends ReactContextBaseJavaModule implements | @@ -186,14 +186,18 @@ public class AMapGeolocationModule extends ReactContextBaseJavaModule implements | ||
186 | client.setLocationOption(option); | 186 | client.setLocationOption(option); |
187 | } | 187 | } |
188 | 188 | ||
189 | - @ReactMethod | ||
190 | - public void reverseGeoCode(double lat, double lng, Promise promise) { | 189 | + @ReactMethod |
190 | + public void reverseGeoCode(double lat, double lng, Float radius, Promise promise) { | ||
191 | if (lat <= 0 || lng <= 0) { | 191 | if (lat <= 0 || lng <= 0) { |
192 | promise.reject(String.valueOf(-2), "无效的经纬度"); | 192 | promise.reject(String.valueOf(-2), "无效的经纬度"); |
193 | return; | 193 | return; |
194 | } | 194 | } |
195 | LatLonPoint poi = new LatLonPoint(lat, lng); | 195 | LatLonPoint poi = new LatLonPoint(lat, lng); |
196 | - RegeocodeQuery regeocodeQuery = new RegeocodeQuery(poi, 100.0F, GeocodeSearch.AMAP); | 196 | + RegeocodeQuery regeocodeQuery = new RegeocodeQuery(poi, 50.0F, GeocodeSearch.AMAP); |
197 | + if (radius != null && radius >= 0f) { | ||
198 | + regeocodeQuery.setRadius(radius); | ||
199 | + } | ||
200 | + regeocodeQuery.setPoiType(""); | ||
197 | try { | 201 | try { |
198 | RegeocodeAddress fromLocation = geocodeSearch.getFromLocation(regeocodeQuery); | 202 | RegeocodeAddress fromLocation = geocodeSearch.getFromLocation(regeocodeQuery); |
199 | if (!fromLocation.getFormatAddress().isEmpty()) { | 203 | if (!fromLocation.getFormatAddress().isEmpty()) { |
lib/src/amap-geolocation.ts
@@ -361,16 +361,21 @@ export function setLocatingWithReGeocode(withReGeocode: boolean) { | @@ -361,16 +361,21 @@ export function setLocatingWithReGeocode(withReGeocode: boolean) { | ||
361 | 361 | ||
362 | /** | 362 | /** |
363 | * 获取经纬度对应的位置描述 | 363 | * 获取经纬度对应的位置描述 |
364 | + * @param lat 纬度 | ||
365 | + * @param lng 经度 | ||
366 | + * @param radius 精度(米) | ||
367 | + * @returns | ||
364 | * | 368 | * |
365 | * @see https://lbs.amap.com/api/android-sdk/guide/map-data/geo#reverse-geocode | 369 | * @see https://lbs.amap.com/api/android-sdk/guide/map-data/geo#reverse-geocode |
366 | */ | 370 | */ |
367 | -export function reverseGeoCode(lat = 0.0, lng = 0.0): Promise<ReGeocode> { | ||
368 | - return AMapGeolocation.reverseGeoCode(lat, lng); | 371 | +export function reverseGeoCode(lat = 0.0, lng = 0.0, radius = -1.0): Promise<ReGeocode> { |
372 | + return AMapGeolocation.reverseGeoCode(lat, lng, radius); | ||
369 | } | 373 | } |
370 | 374 | ||
371 | /** | 375 | /** |
372 | * 地点查询 | 376 | * 地点查询 |
373 | - * | 377 | + * @param keyWord 关键字 |
378 | + * @param city 城市 | ||
374 | * @see https://lbs.amap.com/demo/sdk/place-search#android | 379 | * @see https://lbs.amap.com/demo/sdk/place-search#android |
375 | */ | 380 | */ |
376 | export function searchPoi(keyWord: string, city: string): Promise<PoiSearchResult> { | 381 | export function searchPoi(keyWord: string, city: string): Promise<PoiSearchResult> { |
package.json
1 | { | 1 | { |
2 | "name": "@cqfw/react-native-amap3d", | 2 | "name": "@cqfw/react-native-amap3d", |
3 | - "version": "0.0.7", | 3 | + "version": "0.1.0", |
4 | "description": "react-native 高德地图组件,支持 Android + iOS", | 4 | "description": "react-native 高德地图组件,支持 Android + iOS", |
5 | "author": "feewee", | 5 | "author": "feewee", |
6 | "license": "MIT", | 6 | "license": "MIT", |