手机
当前位置:查字典教程网 >编程开发 >IOS开发 >ios如何根据经纬度坐标取详细地址
ios如何根据经纬度坐标取详细地址
摘要:以当前手机为例:获取当前手机地址,再从经纬度转换成详细地址(包括:国家名-国家代码,省,市,街道名,邮政代代码等)。1:获取当前手机经纬度R...

以当前手机为例:

获取当前手机地址,再从经纬度转换成详细地址(包括:国家名-国家代码,省,市,街道名,邮政代代码等)。

1:获取当前手机经纬度

Reverse geoder Class

1:- (void)startedReverseGeoderWithLatitude:(double)latitude longitude:(double)longitude{ CLLocationCoordinate2D coordinate2D; coordinate2D.longitude = longitude; titude = latitude; // if (self.locationInfo == nil) { self.locationInfo = [[[Location alloc] init] autorelease]; } titude = latitude; self.locationInfo.longitude = longitude; // MKReverseGeocoder *geoCoder = [[MKReverseGeocoder alloc] initWithCoordinate:coordinate2D]; geoCoder.delegate = self; [geoCoder start];}#pragma mark -#pragma mark MKReverseGeocoderDelegate methods- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark { NSLog(@"reverse finished..."); NSLog(@"country:%@",placemark.country); NSLog(@"countryCode:%@",placemark.countryCode); NSLog(@"locality:%@",placemark.locality); NSLog(@"subLocality:%@",placemark.subLocality); NSLog(@"postalCode:%@",placemark.postalCode); NSLog(@"subThoroughfare:%@",placemark.subThoroughfare); NSLog(@"thoroughfare:%@",placemark.thoroughfare); NSLog(@"administrativeArea:%@",placemark.administrativeArea); self.locationInfo.locationName = [NSString stringWithFormat:@"%@ %@,%@ %@,%@", placemark.country, placemark.administrativeArea, placemark.locality, placemark.subLocality, placemark.thoroughfare]; NSLog(@"administrativeArea:%@",self.locationInfo.locationName); [self.target performSelector:self.callBack withObject:@"0"]; geocoder = nil;}- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error { NSLog(@"error %@" , error); [self.target performSelector:self.callBack withObject:@"1"];}

2:获取当前手机经纬度的, 详细地址。

Current location class

-(void) startUpdatingLocation{ // Start the location manager. [[selflocationManager] startUpdatingLocation]; }#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;}/** 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 { [self.target performSelector:self.callBack withObject:@"0"];}- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { [self.target performSelector:self.callBack withObject:@"1"];}

【ios如何根据经纬度坐标取详细地址】相关文章:

IOS开发:Web App导航设计探讨

xcode 4 制作静态库图文详解

iOS应用开发中StoryBoard搭建UI界面的基本使用讲解

iOS中如何判断中英文混合的字符长度

一行代码实现IOS 3DES加密解密

ios下移动文件方法汇总

仿IOS效果 带弹簧动画的ListView

iOS中定位当前位置坐标及转换为火星坐标的方法

iOS如何保持程序在后台长时间运行

iOS 9 更新之Safari广告拦截器(Content Blocker)开发教程

精品推荐
分类导航