Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
devfd committed Jul 15, 2016
2 parents 1d3e083 + b18be62 commit 8462256
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ both iOS and Android will return the following object:
## Notes

### iOS
iOS does not allow sending multiple geocoding requests simultaneously.
iOS does not allow sending multiple geocoding requests simultaneously, unless you enable the fallbackToGoogle to handle the parallel calls when an native iOS request is active.

### Android
geocoding may not work on older android devices (4.1) and will not work if Google play services are not available.
Expand Down
12 changes: 8 additions & 4 deletions ios/RNGeocoder/RNGeocoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ @implementation RNGeocoder
self.geocoder = [[CLGeocoder alloc] init];
}

[self.geocoder cancelGeocode];
if (self.geocoder.geocoding) {
return reject(@"NOT_AVAILABLE", @"geocodePosition busy", nil);
}

[self.geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {

Expand All @@ -55,16 +57,18 @@ @implementation RNGeocoder
self.geocoder = [[CLGeocoder alloc] init];
}

[self.geocoder cancelGeocode];
if (self.geocoder.geocoding) {
return reject(@"NOT_AVAILABLE", @"geocodeAddress busy", nil);
}

[self.geocoder geocodeAddressString:address completionHandler:^(NSArray *placemarks, NSError *error) {

if (error) {
if (placemarks.count == 0) {
return reject(@"NOT_FOUND", @"geocodePosition failed", error);
return reject(@"NOT_FOUND", @"geocodeAddress failed", error);
}

return reject(@"ERROR", @"geocodePosition failed", error);
return reject(@"ERROR", @"geocodeAddress failed", error);
}

resolve([self placemarksToDictionary:placemarks]);
Expand Down

0 comments on commit 8462256

Please sign in to comment.