Autocomplete API with Google Maps SDK on iOS

Gmap

By Using the following code you can integrate the Google Maps SDK in your iOS project.

First we will write the function which results the array of related nearby places.

  1. -(void) searchLocation:(NSString *)locationName{
  2.   GMSAutocompleteFilter *filter;
  3.   filter.type=kGMSPlacesAutocompleteTypeFilterGeocode;
  4.   GMSVisibleRegion visibleRegion = _mapView.projection.visibleRegion;
  5.   GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithRegion: visibleRegion];
  6.   [[GMSPlacesClient new] autocompleteQuery:locationName bounds:bounds filter:filter callback:^(NSArray *results,NSError *error){
  7.       if (error != nil) {
  8.           [locationAray removeAllObjects];
  9.           [self.locationTableView reloadData];
  10.           return;
  11.       }
  12.       if ([results count]>0) {
  13.           [locationAray removeAllObjects];
  14.           [locationAray addObjectsFromArray:results];
  15.           [self.locationTableView reloadData];
  16.       }

Read the full blog about Autocomplete API with Google Maps SDK on iOS visit Findnerd.

 

Advertisements
Autocomplete API with Google Maps SDK on iOS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s