Skip to content

Commit 05ed3e7

Browse files
author
lovebing
committed
Update reverseGeoCode callback
1 parent 227b950 commit 05ed3e7

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ project(':react-native-baidu-map').projectDir = new File(settingsDir, '../node_m
7676

7777
| Method | Result
7878
| ------------------------- | -------
79-
| Promise reverseGeoCode(double lat, double lng) | {"address": ""}
80-
| Promise reverseGeoCodeGPS(double lat, double lng) | {"address": ""}
79+
| Promise reverseGeoCode(double lat, double lng) | `{"address": "", "province": "", "city": "", "district": "", "streetName": "", "streetNumber": ""}`
80+
| Promise reverseGeoCodeGPS(double lat, double lng) | `{"address": "", "province": "", "city": "", "district": "", "streetName": "", "streetNumber": ""}`
8181
| Promise geocode(String city, String addr) | {"latitude": 0.0, "longitude": 0.0}
8282
| 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": ""}`

android/src/main/java/org/lovebing/reactnative/baidumap/GeolocationModule.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,13 @@ public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) {
148148
params.putInt("errcode", -1);
149149
}
150150
else {
151-
params.putString("address", result.getAddress());
151+
ReverseGeoCodeResult.AddressComponent addressComponent = result.getAddressDetail();
152+
params.putString("address", result.getAddress());
153+
params.putString("province", addressComponent.province);
154+
params.putString("city", addressComponent.city);
155+
params.putString("district", addressComponent.district);
156+
params.putString("street", addressComponent.street);
157+
params.putString("streetNumber", addressComponent.streetNumber);
152158
}
153159
sendEvent("onGetReverseGeoCodeResult", params);
154160
}

demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"dependencies": {
99
"react": "15.2.1",
1010
"react-native": "^0.30.0",
11-
"react-native-baidu-map": "^0.4.7"
11+
"react-native-baidu-map": "^0.4.8"
1212
}
1313
}

ios/RCTBaiduMap/GeolocationModule.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ -(void) onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKRevers
118118

119119
if (error == BMK_SEARCH_NO_ERROR) {
120120
body[@"address"] = result.address;
121+
body[@"province"] = result.addressDetail.province;
122+
body[@"city"] = result.addressDetail.city;
123+
body[@"district"] = result.addressDetail.district;
124+
body[@"streetName"] = result.addressDetail.streetName;
125+
body[@"streetNumber"] = result.addressDetail.streetNumber;
121126
}
122127
else {
123128
body[@"errcode"] = [NSString stringWithFormat:@"%d", error];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-baidu-map",
3-
"version": "0.4.7",
3+
"version": "0.4.8",
44
"description": "Baidu Map SDK modules and view for React Native(Android & IOS), support react native 0.30+.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)