From 05ed3e7885fa469db15ffb17269b328366e61cd0 Mon Sep 17 00:00:00 2001 From: lovebing Date: Sat, 29 Oct 2016 00:11:46 +0800 Subject: [PATCH] Update reverseGeoCode callback --- README.md | 4 ++-- .../lovebing/reactnative/baidumap/GeolocationModule.java | 8 +++++++- demo/package.json | 2 +- ios/RCTBaiduMap/GeolocationModule.m | 5 +++++ package.json | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0243e8e8..51d02c85 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ project(':react-native-baidu-map').projectDir = new File(settingsDir, '../node_m | Method | Result | ------------------------- | ------- -| Promise reverseGeoCode(double lat, double lng) | {"address": ""} -| Promise reverseGeoCodeGPS(double lat, double lng) | {"address": ""} +| Promise reverseGeoCode(double lat, double lng) | `{"address": "", "province": "", "city": "", "district": "", "streetName": "", "streetNumber": ""}` +| Promise reverseGeoCodeGPS(double lat, double lng) | `{"address": "", "province": "", "city": "", "district": "", "streetName": "", "streetNumber": ""}` | Promise geocode(String city, String addr) | {"latitude": 0.0, "longitude": 0.0} | Promise getCurrentPosition() | IOS: `{"latitude": 0.0, "longitude": 0.0}` Android: `{"latitude": 0.0, "longitude": 0.0, "direction": -1, "altitude": 0.0, "radius": 0.0, "address": "", "countryCode": "", "country": "", "province": "", "cityCode": "", "city": "", "district": "", "street": "", "streetNumber": "", "buildingId": "", "buildingName": ""}` diff --git a/android/src/main/java/org/lovebing/reactnative/baidumap/GeolocationModule.java b/android/src/main/java/org/lovebing/reactnative/baidumap/GeolocationModule.java index 451c1f62..caadb1f5 100644 --- a/android/src/main/java/org/lovebing/reactnative/baidumap/GeolocationModule.java +++ b/android/src/main/java/org/lovebing/reactnative/baidumap/GeolocationModule.java @@ -148,7 +148,13 @@ public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) { params.putInt("errcode", -1); } else { - params.putString("address", result.getAddress()); + ReverseGeoCodeResult.AddressComponent addressComponent = result.getAddressDetail(); + params.putString("address", result.getAddress()); + params.putString("province", addressComponent.province); + params.putString("city", addressComponent.city); + params.putString("district", addressComponent.district); + params.putString("street", addressComponent.street); + params.putString("streetNumber", addressComponent.streetNumber); } sendEvent("onGetReverseGeoCodeResult", params); } diff --git a/demo/package.json b/demo/package.json index 24353479..08c17b80 100644 --- a/demo/package.json +++ b/demo/package.json @@ -8,6 +8,6 @@ "dependencies": { "react": "15.2.1", "react-native": "^0.30.0", - "react-native-baidu-map": "^0.4.7" + "react-native-baidu-map": "^0.4.8" } } diff --git a/ios/RCTBaiduMap/GeolocationModule.m b/ios/RCTBaiduMap/GeolocationModule.m index 65518560..94a1ae82 100644 --- a/ios/RCTBaiduMap/GeolocationModule.m +++ b/ios/RCTBaiduMap/GeolocationModule.m @@ -118,6 +118,11 @@ -(void) onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKRevers if (error == BMK_SEARCH_NO_ERROR) { body[@"address"] = result.address; + body[@"province"] = result.addressDetail.province; + body[@"city"] = result.addressDetail.city; + body[@"district"] = result.addressDetail.district; + body[@"streetName"] = result.addressDetail.streetName; + body[@"streetNumber"] = result.addressDetail.streetNumber; } else { body[@"errcode"] = [NSString stringWithFormat:@"%d", error]; diff --git a/package.json b/package.json index 15066fd1..76d03d12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-baidu-map", - "version": "0.4.7", + "version": "0.4.8", "description": "Baidu Map SDK modules and view for React Native(Android & IOS), support react native 0.30+.", "main": "index.js", "scripts": {