How to make Swift ios 8 input field automatic

I am trying to create a simple application that 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 that found on google maps. In particular, I would like some kind of autocomplete to ensure that the user enters a valid address. Is it possible to create an instance of the Google map search box?

+4
source share
1 answer

SPGooglePlacesAutocomplete is a simple objective-c wrapper around the Google Places auto-complete API.

Take a look at this API from github, which can be useful https://github.com/spoletto/SPGooglePlacesAutocomplete

Use is shown here. By adding the .h file, you can access functions that implement the Google APIs from within the function. You can set parameters such as partial address bar, radius, language used by your application, 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 check the Google APIs and get the results. The resulting array will return objects of class SPGooglePlacesAutocompletePlace.

[query fetchPlaces:^(NSArray *places, NSError *error) {
    NSLog(@"Places returned %@", places);
}];

He also has a sample project that can be used.

+1
source

All Articles