Sto cercando di utilizzare (inoltro) geocoding utilizzando le nuove API CLLocationManager in iOS 5 e non sto avendo fortuna.CLLocationManager geocodeAddressString: inRegion non funziona per vincolare la regione (ios5)
sto specificando una regione in base alla posizione corrente, ma mi sta dando risultati sul dall'altra parte del mondo.
//CLLocation *currentloc is set to the current location when I get in here (<+37.78583400,-122.40641700>)
CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:[currentloc coordinate] radius:5000 /*meters*/ identifier:@"You are here"];
// Region is now: (identifier You are here) <+37.78583400,-122.40641700> radius 5000.00m
NSString *addressString = @"Citibank"; //for example
[geoCoder geocodeAddressString:addressString inRegion:region completionHandler:^(NSArray* placemarks, NSError* error){
for (CLPlacemark* aPlacemark in placemarks)
{ // Process the placemark.
NSLog(@"Got Placemark : %@", aPlacemark);
}
}];
E tutto quello che ottiene è:
> 2011-12-14 15:50:49.882 [12377:12503] Got Placemark : Citibank, New
> Delhi, Delhi, India @ <+28.63470640,+77.22010140> +/- 100.00m, region
> (identifier <+28.63517750,+77.21878050> radius 154.35)
> <+28.63517750,+77.21878050> radius 154.35m
>
> 2011-12-14 15:50:49.883[12377:12503] Got Placemark : CitiBank, Noida,
> Uttar Pradesh, India @ <+28.58157180,+77.32408380> +/- 100.00m, region
> (identifier <+28.58161950,+77.32315050> radius 154.41)
> <+28.58161950,+77.32315050> radius 154.41m
>
> 2011-12-14 15:50:49.885 [12377:12503] Got Placemark : Citibank, New
> Delhi, Delhi, India @ <+28.53627320,+77.21128390> +/- 100.00m, region
> (identifier <+28.53630050,+77.21054050> radius 154.46)
> <+28.53630050,+77.21054050> radius 154.46m
>
> ...
Tutte le idee:
lo fa pensare che io sia a Nuova Delhi? (Penso che la risposta è no -? Perché una ricerca per "All Star Donuts" con lo stesso inRegion mi mette in Thailandia
Perchè sono cattivo uso "inRegion"
fa questo lavoro per chiunque perché sarà sarebbe bello se e quando lo fa
ho trovato una soluzione per questo problema utilizzando il metodo 'geocodeAddressString: completionHandler:' invece. Date un'occhiata a [la mia soluzione] (http://stackoverflow.com/questions/10202550/clgeocoder-returning-locations-in-other-countries/13632049#13632049) per una domanda molto simile. – msoler