Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump google maps #2

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions ios/NSMutableDictionary+GMSPlace.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ + (instancetype)dictionaryWithGMSPlace:(GMSPlace*)place
if (place.rating) {
placeData[@"rating"] = [NSNumber numberWithDouble:place.rating];
}

if (place.viewport) {
NSMutableDictionary *viewportMap = [[NSMutableDictionary alloc] init];
viewportMap[@"latitudeNE"] = [NSNumber numberWithDouble:place.viewport.northEast.latitude];
viewportMap[@"longitudeNE"] = [NSNumber numberWithDouble:place.viewport.northEast.longitude];
viewportMap[@"latitudeSW"] = [NSNumber numberWithDouble:place.viewport.southWest.latitude];
viewportMap[@"longitudeSW"] = [NSNumber numberWithDouble:place.viewport.southWest.longitude];

placeData[@"viewport"] = viewportMap;
}

if (place.plusCode) {
NSMutableDictionary *plusCodeMap = [[NSMutableDictionary alloc] init];
Expand Down
1 change: 0 additions & 1 deletion ios/RNGooglePlaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

- (GMSPlacesAutocompleteTypeFilter) getFilterType:(NSString *)type;
- (GMSPlaceField) getSelectedFields:(NSArray *)fields isCurrentOrFetchPlace:(Boolean)currentOrFetch;
- (GMSCoordinateBounds *) getBounds: (NSDictionary *)biasOptions andRestrictOptions: (NSDictionary *)restrictOptions;

@end

46 changes: 1 addition & 45 deletions ios/RNGooglePlaces.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
@interface RNGooglePlaces() <CLLocationManagerDelegate>

@property (strong, nonatomic) CLLocationManager *locationManager;
@property GMSAutocompleteBoundsMode boundsMode;
@property GMSAutocompleteSessionToken *sessionToken;

@end
Expand Down Expand Up @@ -41,8 +40,6 @@ - (instancetype)init
_instance = self;
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;

self.boundsMode = kGMSAutocompleteBoundsModeBias;
}

return self;
Expand Down Expand Up @@ -83,10 +80,8 @@ - (void)cancelAutocompleteSession
NSDictionary *locationBias = [RCTConvert NSDictionary:options[@"locationBias"]];
NSDictionary *locationRestriction = [RCTConvert NSDictionary:options[@"locationRestriction"]];


GMSCoordinateBounds *autocompleteBounds = [self getBounds:locationBias andRestrictOptions:locationRestriction];

[acController openAutocompleteModal: autocompleteFilter placeFields: selectedFields bounds: autocompleteBounds boundsMode: self.boundsMode resolver: resolve rejecter: reject];
[acController openAutocompleteModal: autocompleteFilter placeFields: selectedFields resolver: resolve rejecter: reject];
}
@catch (NSException * e) {
reject(@"E_OPEN_FAILED", @"Could not open modal", [self errorFromException:e]);
Expand All @@ -106,11 +101,7 @@ - (void)cancelAutocompleteSession
NSDictionary *locationBias = [RCTConvert NSDictionary:options[@"locationBias"]];
NSDictionary *locationRestriction = [RCTConvert NSDictionary:options[@"locationRestriction"]];

GMSCoordinateBounds *autocompleteBounds = [self getBounds:locationBias andRestrictOptions:locationRestriction];

[[GMSPlacesClient sharedClient] findAutocompletePredictionsFromQuery:query
bounds:autocompleteBounds
boundsMode:self.boundsMode
filter:autocompleteFilter
sessionToken:self.sessionToken
callback:^(NSArray<GMSAutocompletePrediction *> * _Nullable results, NSError *error) {
Expand Down Expand Up @@ -284,41 +275,6 @@ - (GMSPlaceField) getSelectedFields:(NSArray *)fields isCurrentOrFetchPlace:(Boo
return GMSPlaceFieldAll;
}

- (GMSCoordinateBounds *) getBounds: (NSDictionary *)biasOptions andRestrictOptions: (NSDictionary *)restrictOptions
{
double biasLatitudeSW = [[RCTConvert NSNumber:biasOptions[@"latitudeSW"]] doubleValue];
double biasLongitudeSW = [[RCTConvert NSNumber:biasOptions[@"longitudeSW"]] doubleValue];
double biasLatitudeNE = [[RCTConvert NSNumber:biasOptions[@"latitudeNE"]] doubleValue];
double biasLongitudeNE = [[RCTConvert NSNumber:biasOptions[@"longitudeNE"]] doubleValue];

double restrictLatitudeSW = [[RCTConvert NSNumber:restrictOptions[@"latitudeSW"]] doubleValue];
double restrictLongitudeSW = [[RCTConvert NSNumber:restrictOptions[@"longitudeSW"]] doubleValue];
double restrictLatitudeNE = [[RCTConvert NSNumber:restrictOptions[@"latitudeNE"]] doubleValue];
double restrictLongitudeNE = [[RCTConvert NSNumber:restrictOptions[@"longitudeNE"]] doubleValue];

if (biasLatitudeSW != 0 && biasLongitudeSW != 0 && biasLatitudeNE != 0 && biasLongitudeNE != 0) {
CLLocationCoordinate2D neBoundsCorner = CLLocationCoordinate2DMake(biasLatitudeNE, biasLongitudeNE);
CLLocationCoordinate2D swBoundsCorner = CLLocationCoordinate2DMake(biasLatitudeSW, biasLongitudeSW);
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:neBoundsCorner
coordinate:swBoundsCorner];

return bounds;
}

if (restrictLatitudeSW != 0 && restrictLongitudeSW != 0 && restrictLatitudeNE != 0 && restrictLongitudeNE != 0) {
CLLocationCoordinate2D neBoundsCorner = CLLocationCoordinate2DMake(restrictLatitudeNE, restrictLongitudeNE);
CLLocationCoordinate2D swBoundsCorner = CLLocationCoordinate2DMake(restrictLatitudeSW, restrictLongitudeSW);
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:neBoundsCorner
coordinate:swBoundsCorner];

self.boundsMode = kGMSAutocompleteBoundsModeRestrict;

return bounds;
}

return nil;
}


@end

2 changes: 0 additions & 2 deletions ios/RNGooglePlacesViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

- (void)openAutocompleteModal: (GMSAutocompleteFilter *)autocompleteFilter
placeFields: (GMSPlaceField)selectedFields
bounds: (GMSCoordinateBounds *)autocompleteBounds
boundsMode: (GMSAutocompleteBoundsMode)autocompleteBoundsMode
resolver: (RCTPromiseResolveBlock)resolve
rejecter: (RCTPromiseRejectBlock)reject;

Expand Down
4 changes: 0 additions & 4 deletions ios/RNGooglePlacesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ - (instancetype)init

- (void)openAutocompleteModal: (GMSAutocompleteFilter *)autocompleteFilter
placeFields: (GMSPlaceField)selectedFields
bounds: (GMSCoordinateBounds *)autocompleteBounds
boundsMode: (GMSAutocompleteBoundsMode)autocompleteBoundsMode
resolver: (RCTPromiseResolveBlock)resolve
rejecter: (RCTPromiseRejectBlock)reject;
{
Expand All @@ -36,8 +34,6 @@ - (void)openAutocompleteModal: (GMSAutocompleteFilter *)autocompleteFilter

GMSAutocompleteViewController *viewController = [[GMSAutocompleteViewController alloc] init];
viewController.autocompleteFilter = autocompleteFilter;
viewController.autocompleteBounds = autocompleteBounds;
viewController.autocompleteBoundsMode = autocompleteBoundsMode;
viewController.placeFields = selectedFields;
viewController.delegate = self;
UIViewController *topController = [self getTopController];
Expand Down
6 changes: 3 additions & 3 deletions react-native-google-places.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ Pod::Spec.new do |s|
s.homepage = 'https://github.com/tolu360/react-native-google-places'
s.source = { :git => 'https://github.com/tolu360/react-native-google-places.git', :tag => s.version }

s.platform = :ios, '9.0'
s.platform = :ios, '11.0'

s.preserve_paths = 'README.md', 'package.json', 'index.js'
s.source_files = 'ios/*.{h,m}'

s.compiler_flags = '-DHAVE_GOOGLE_MAPS=1', '-fno-modules'

s.dependency 'React'
s.dependency 'GooglePlaces', '~> 3.2.0'
s.dependency 'GoogleMaps', '~> 3.2.0'
s.dependency 'GooglePlaces', '5.1.0'
s.dependency 'GoogleMaps', '5.1.0'
end