CLGeocoder Only Returning One Placemark
Asked Answered
H

2

9

I have a problem with CLGeocoder where when I call geocodeAddressString:withCompletionHandler I only ever get one result back, despite knowing that the inputted string should return more than one value. The class reference even states:

In the case of forward-geocoding requests, multiple placemark objects may be returned if the provided information yielded multiple possible locations.

However, my placemarks array only ever has one item in it:

    [geocoderDestination geocodeAddressString:destination completionHandler:^(NSArray *placemarks, NSError *error){
NSLog(@"array count:%i", [placemarks count];}

Thank you for any help.


I have used strings such as "Piccadilly, UK", "Union Street, UK" which have only returned one result. Now that I think about it, putting UK on the end might be the contributing factor.

Hurlee answered 5/7, 2012 at 12:17 Comment(3)
you can add your sample string, so that others can test for themselvesDecollate
Done, but I think I've realised my error now hahaha. But the problem is that I need the results to be UK specific, and using geocodeAddressString:inRegion: is not very good as you have to assign a radius, so some of Ireland would be included.Hurlee
Well this is taking the piss, even if I use CLLocationDistance distance1 = 750; CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:CLLocationCoordinate2DMake(53.825564, -2.421976) radius:distance1 identifier:nil]; with geocodeAddressString:inRegion: then it gives me some place in Australia for "Piccadilly".Hurlee
S
4

I dont know about CLGeocoder but if your requirement is a location search another way is to use google location search url http://maps.google.com/maps/geo?q=london which returns a json containing the matched location information.

Scutum answered 6/7, 2012 at 4:40 Comment(1)
Thanks, I will use that in the meantime as I still can't get this workingHurlee
B
1

Instead of UK use United Kingdom it will give you some related result.
Try to add some more info in your address.
One more thing UK is not a valid country code it's GB but it seems that putting GB instead of UK didn't solve the problem.
Moreover CLGeocoder is not as smart as Google Maps API right now because apple uses its own server to decode addresses so you can use Google services.

Bellinger answered 8/7, 2012 at 5:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.