[转Iphone]根据经纬度坐标取详细地址(包括国,省,市,街道,号)
来源:互联网 发布:知乎 三公子 编辑:程序博客网 时间:2024/04/29 16:14
获取当前手机地址,再从经纬度转换成详细地址(包括:国家名-国家代码,省,市,街道名,邮政代代码等)。
1:获取当前手机经纬度
@implementation CurrentLocation@synthesize locationManager;@synthesize target,callBack;#pragma mark --#pragma mark Public-(void) startUpdatingLocation{[[self locationManager] startUpdatingLocation];}#pragma mark --#pragma mark Memory management-(void) dealloc{[super dealloc];[locationManager release];}#pragma mark --#pragma mark Location manager/* Return a location manager -- create one if necessary. */- (CLLocationManager *)locationManager { if (locationManager != nil) {return locationManager;} locationManager = [[CLLocationManager alloc] init]; [locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters]; [locationManager setDelegate:self]; return locationManager;}#pragma mark --#pragma mark CLLocationManagerDelegate methods/* Conditionally enable the Add button: If the location manager is generating updates, then enable the button; If the location manager is failing, then disable the button. */- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {NSLog(@"获取到经纬度!");}- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { NSLog(@"获取失败!"); }@end
2: 获取当前手机经纬度的详细地址
@implementation AddressReverseGeoder#pragma mark --#pragma mark Public//根据经纬度开始获取详细地址信息- (void)startedReverseGeoderWithLatitude:(double)latitude longitude:(double)longitude{CLLocationCoordinate2D coordinate2D;coordinate2D.longitude = longitude;coordinate2D.latitude = latitude;//MKReverseGeocoder *geoCoder = [[MKReverseGeocoder alloc] initWithCoordinate:coordinate2D];geoCoder.delegate = self;[geoCoder start];}#pragma mark --#pragma mark MKReverseGeocoderDelegate methods//获得地址信息- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {NSString *address = [NSString stringWithFormat:@"%@ %@ %@ %@ %@%@", placemark.country, placemark.administrativeArea, placemark.locality, placemark.subLocality, placemark.thoroughfare, placemark.subThoroughfare];NSLog(@"经纬度所对应的详细:%@", address);geocoder = nil;}//错误处理- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {NSLog(@"error %@" , error);}#pragma mark --#pragma mark Memory management- (void)dealloc { [super dealloc];}@end
@property (nonatomic, readonly) NSDictionary *addressDictionary; //地址字典
@property (nonatomic, readonly) NSString *thoroughfare; //街道名——“科韵路”
@property (nonatomic, readonly) NSString *subThoroughfare; // 门牌号——“18号”
@property (nonatomic, readonly) NSString *locality; //城市——“广州市”
@property (nonatomic, readonly) NSString *subLocality; //区县——“天河区”
@property (nonatomic, readonly) NSString *administrativeArea; //身份——“广东省”
@property (nonatomic, readonly) NSString *subAdministrativeArea; //没获取到,不知道是什么东东
@property (nonatomic, readonly) NSString *postalCode; //邮政编码——不知道是什么原因,这里没获取到
@property (nonatomic, readonly) NSString *country; //国家——“中国”
@property (nonatomic, readonly) NSString *countryCode; //国家代码——“CN”
- [转Iphone]根据经纬度坐标取详细地址(包括国,省,市,街道,号)
- 根据详细地址获取经纬度
- 根据详细地址获取经纬度
- 经纬度转详细地址
- 根据地址和关键字查找详细地址经纬度
- 根据经纬度坐标计算距离
- 根据鼠标坐标取该坐标下的元素,包括touch
- 平面坐标转大地坐标(经纬度)
- Google Map 根据经纬度获取当前具体街道位置
- iOS获取地理位置,根据经纬度获取省市街道
- 根据经纬度画多边形(返回各个顶点坐标)
- 根据经纬度坐标计算实际距离
- PHP根据两个经纬度坐标计算距离
- openlayers 根据经纬度转换为屏幕坐标
- mysql函数-根据经纬度坐标计算距离
- 根据两点经纬度坐标计算距离
- 百度地图根据地理坐标转换经纬度
- c++根据两点经纬度坐标获取长度
- GCC静态编译32位程序
- Porting Android to S3C6410
- Talking about Android Message Queue
- 关于简单模式的一点体会
- 读取数据库数据到html table中
- [转Iphone]根据经纬度坐标取详细地址(包括国,省,市,街道,号)
- 分页的代码
- Android模拟器上安装和卸载APK
- [转Iphone]获取当前位置
- 从简单模式到策略模式
- 枚举窗口代码
- 软件测试(杂谈)
- IT自由职业者的成功秘诀
- 程序员从初级到中级10个秘诀