iOS6以降で住所から緯度経度を検索するにはどうすればいいのだろうか?
下記のようにgeocodeAddressStringメソッドを使えば取得することができるみたいだ。
NSString *address;
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:address
completionHandler:^(NSArray* placemarks, NSError* error){
for (CLPlacemark* aPlacemark in placemarks){
CLLocation *cLLocation = aPlacemark.location;
CLLocationCoordinate2D coordinate = cLLocation.coordinate;
NSLog(@"long is %f lat is %f",coordinate.longitude,coordinate.latitude);
}
}];これ、検索しても返ってこないときがあるのだが、何故??
0 コメント:
コメントを投稿