How to show and search in google autocomplete just place my current city(area)?

649 Views Asked by At

There are problems with auto complete, to me google autocomplete search bar is filling writes all cities in the world but I need only the address of my city.

3

There are 3 best solutions below

0
On

You can use the GMSCoordinateBounds, which is

A object which restrict the results to a specific area specified by latitude and longitude bounds.

In additional, There are some Location Biasing options for the JS API, but no sure if iOS API has them too.

0
On

I found information, we cant search just in city.We can minimum set search in Country. Google say - they will fix it in next version.

NSMutableString *url = [NSMutableString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/autocomplete/json?input=%@&sensor=%@&components=country:%@""&key=%@",
                                                         [input stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
                                                         SPBooleanStringForBool(sensor), countryCode,key];
0
On

This worked for me:

GMSVisibleRegion visibleRegion = self.mapView.projection.visibleRegion;
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:visibleRegion.farLeft coordinate:visibleRegion.nearRight];