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

implementation of component filtering #27

Merged
merged 1 commit into from
Mar 27, 2014

Conversation

bananita
Copy link
Contributor

@bananita bananita commented Aug 2, 2013

Components filtering is really important feature of Google Geocoder API, because bounds are sometimes insufficient. For example query with London bounds:

http://maps.googleapis.com/maps/api/geocode/json?bounds=51.417512%2C-0.271765%7C51.597274%2C0.016299&language=en&address=New%20York&sensor=true

will return New York, USA.
It happens because bounds are just suggestion.

The solution of this issue is using component filtering. Query below:

http://maps.googleapis.com/maps/api/geocode/json?language=en&bounds=51.417512%2C-0.271765%7C51.597274%2C0.016299&components=locality%3ALondon%7Ccountry%3AGB&address=New%20York&sensor=true

will return expected results.

I've pushed implementation of constructors and class methods allowing component filtering.

Example of usage:

CLLocationCoordinate2D londonCenter =
CLLocationCoordinate2DMake(51.507393, -0.127733);


CLRegion* region = [[CLRegion alloc]
                    initCircularRegionWithCenter:londonCenter
                    radius:20000
                    identifier:@"London Region"];

id components = @{SVGeocoderComponentLocality: @"London",
                  SVGeocoderCountry: @"GB"};

[SVGeocoder geocode:@"New York" region:region components:components completion:^(NSArray *placemarks, NSHTTPURLResponse *urlResponse, NSError *error) {
    [placemarks enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        NSLog(@"%@", obj);
    }];
}];

Regards,
Michał

@lotz
Copy link

lotz commented Aug 6, 2013

Thank Michał. I would definitely use this feature too.

@JanC
Copy link

JanC commented Feb 11, 2014

will this be ever merged to the master ?

samvermette added a commit that referenced this pull request Mar 27, 2014
implementation of component filtering
@samvermette samvermette merged commit 780dc53 into TransitApp:master Mar 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants