//
// ViewController.m
// GCoder
//
// Created by lcy on 16/1/14.
// Copyright (c) 2016年 lcy. All rights reserved.
//
#import "ViewController.h"
#import <MapKit/MapKit.h>
//地名 ----> 地理信息
//正向编码 (地名)
//反向编码
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CLGeocoder *coder = [[CLGeocoder alloc] init];
#if 0
//正向
[coder geocodeAddressString:@"深圳大学" completionHandler:^(NSArray *placemarks, NSError *error) {
//CLPlacemark
CLPlacemark *mark = placemarks[0];
//得到位置信息
NSLog(@"%@",mark.location);
NSLog(@"%@",mark.addressDictionary);
//街道信息
NSLog(@"%@",mark.thoroughfare);
NSLog(@"%@",mark.administrativeArea);
}];
#endif
//反向
[coder reverseGeocodeLocation:[[CLLocation alloc] initWithLatitude:22.533367 longitude:113.935404] completionHandler:^(NSArray *placemarks, NSError *error) {
CLPlacemark *mark = placemarks[0];
//街道信息
NSLog(@"%@",mark.thoroughfare);
NSLog(@"%@",mark.subThoroughfare);
NSLog(@"%@",mark.addressDictionary[@"FormattedAddressLines"][0]);
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
iso 自有 正反编码
最新推荐文章于 2022-08-24 21:41:11 发布