I am trying to make a simple app which allows the user to get the longitude and latitude corresponding to a specific address. I want to provide the user with a search box similar to the one in google maps. Specifically I would like some sort of autocompletion to ensure the user enters a valid address. Is it possible to create an instance of google maps search box?
SPGooglePlacesAutocomplete is a simple objective-c wrapper around the Google Places Autocomplete API.
Look at this API from github which might be helpful- https://github.com/spoletto/SPGooglePlacesAutocomplete
Usage shown as per link. Adding the .h file you can have access to the functions which implement the Google places API from within the function. You can set parameters like partial address string, radius, language your app uses, your location (lat,long)
#import "SPGooglePlacesAutocompleteQuery.h"
...
SPGooglePlacesAutocompleteQuery *query = [SPGooglePlacesAutocompleteQuery query];
query.input = @"185 berry str";
query.radius = 100.0;
query.language = @"en";
query.types = SPPlaceTypeGeocode; // Only return geocoding (address) results.
query.location = CLLocationCoordinate2DMake(37.76999, -122.44696)
Then, call -fetchPlaces to ping Google's API and fetch results. The resulting array will return objects of the SPGooglePlacesAutocompletePlace class.
[query fetchPlaces:^(NSArray *places, NSError *error) {
NSLog(@"Places returned %@", places);
}];
It also has a example project which can be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With