アップルマップ地理符号化反地理符号化
3851 ワード
CoreLocation.frameworkはこのフレームワークを使用します
import
import
地図コードはアップルに地名を送って詳細な地名を返す #import "ViewController.h"
#import
@interface ViewController ()
/**
*
*/
@property (nonatomic,strong) CLGeocoder * geocoder;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.geocoder = [[CLGeocoder alloc] init];
// , " "
//
[self.geocoder geocodeAddressString:@" " completionHandler:^(NSArray *placemarks, NSError *error) {
// block
NSLog(@"%@",[NSThread currentThread]);
if (!error) {
// CLPlacemark
for (CLPlacemark *placemark in placemarks) {
NSLog(@" %@",[placemark class]);
NSLog(@" %@",placemark.name);
NSLog(@" %@",placemark.thoroughfare);
NSLog(@" %@",placemark.country);
NSLog(@" %@",placemark.locality);
NSLog(@" : %@",placemark.subLocality);
NSLog(@" %@",placemark.addressDictionary);
NSLog(@"=======
");
}
}else{
NSLog(@"%@",error);
}
}];
}
@end
反地理符号化はアップルに経緯度を送信して詳細な地名オブジェクトを返す怠け者のロードである.
import "ViewController.h" #import
@interface ViewController ()
@property (nonatomic,strong) CLGeocoder * geocoder;
@end
@implementation ViewController
-(CLGeocoder *)geocoder{
if (!_geocoder) {
_geocoder = [[CLGeocoder alloc] init];
}
return _geocoder;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// : " "
// : 113.324675 23.124103
CLLocation *loc = [[CLLocation alloc] initWithLatitude:23.124103 longitude:113.324675];
[self.geocoder reverseGeocodeLocation:loc completionHandler:^(NSArray *placemarks, NSError *error) {
// block
NSLog(@"%@",[NSThread currentThread]);
if (!error) {
// CLPlacemark
for (CLPlacemark *placemark in placemarks) {
NSLog(@" %@",[placemark class]);
NSLog(@" %@",placemark.name);
NSLog(@" %@",placemark.thoroughfare);
NSLog(@" %@",placemark.country);
NSLog(@" %@",placemark.locality);
NSLog(@" : %@",placemark.subLocality);
NSLog(@" %@",placemark.addressDictionary);
NSLog(@"=======
");
}
}else{
NSLog(@"%@",error);
}
}];
}
@end
#import "ViewController.h"
#import
@interface ViewController ()
/**
*
*/
@property (nonatomic,strong) CLGeocoder * geocoder;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.geocoder = [[CLGeocoder alloc] init];
// , " "
//
[self.geocoder geocodeAddressString:@" " completionHandler:^(NSArray *placemarks, NSError *error) {
// block
NSLog(@"%@",[NSThread currentThread]);
if (!error) {
// CLPlacemark
for (CLPlacemark *placemark in placemarks) {
NSLog(@" %@",[placemark class]);
NSLog(@" %@",placemark.name);
NSLog(@" %@",placemark.thoroughfare);
NSLog(@" %@",placemark.country);
NSLog(@" %@",placemark.locality);
NSLog(@" : %@",placemark.subLocality);
NSLog(@" %@",placemark.addressDictionary);
NSLog(@"=======
");
}
}else{
NSLog(@"%@",error);
}
}];
}
@end
#import
@interface ViewController ()
@property (nonatomic,strong) CLGeocoder * geocoder;
@end
@implementation ViewController
-(CLGeocoder *)geocoder{
if (!_geocoder) {
_geocoder = [[CLGeocoder alloc] init];
}
return _geocoder;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// : " "
// : 113.324675 23.124103
CLLocation *loc = [[CLLocation alloc] initWithLatitude:23.124103 longitude:113.324675];
[self.geocoder reverseGeocodeLocation:loc completionHandler:^(NSArray *placemarks, NSError *error) {
// block
NSLog(@"%@",[NSThread currentThread]);
if (!error) {
// CLPlacemark
for (CLPlacemark *placemark in placemarks) {
NSLog(@" %@",[placemark class]);
NSLog(@" %@",placemark.name);
NSLog(@" %@",placemark.thoroughfare);
NSLog(@" %@",placemark.country);
NSLog(@" %@",placemark.locality);
NSLog(@" : %@",placemark.subLocality);
NSLog(@" %@",placemark.addressDictionary);
NSLog(@"=======
");
}
}else{
NSLog(@"%@",error);
}
}];
}
@end