ios通过经纬度定位城市,通过城市名定位经纬度 ios定位获取经纬度

通过经纬度定位城市:

CLGeocoder * geoCoder =[[[CLGeocoder alloc] init] autorelease];

[geoCoderreverseGeocodeLocation:newLocationcompletionHandler:^(NSArray *placemarks, NSError*error) {

for(CLPlacemark * placemark in placemarks) {

NSString *myCity =placemark.locality;

if ([myCity isEqualToString:@"长安"]) {

myCity =@"西安";

}

self.myLabel.text = [NSString stringWithFormat:@"(%@,%@)||%@%@",currentLatitude,currentLongitude,placemark.country,myCity];

if (self.myLabel.text.length > 0) {

[self.locationManager stopUpdatingLocation];

}

ios通过经纬度定位城市,通过城市名定位经纬度 ios定位获取经纬度

}

}];

通过城市名定位经纬度:

CLGeocoder———— * geocoder = [[CLGeocoder alloc] init];
065
066[geocodergeocodeAddressString:_searchTextField.textcompletionHandler:^(NSArray *placemarks, NSError *error){
067
068
069if(error)
070{
071NSLog(@"Geocodererror : %@",error);
072return;
073}
074
075if([placemarkscount] == 0)
076{
077NSLog(@"Couldfound the address.");
078return;
079}
080
081CLPlacemark* placeMark = [placemarks objectAtIndex:0];
082
083_mapView.centerCoordinate= placeMark.location.coordinate;
084
085mAnnotationView* annotationView = [[mAnnotationView alloc]initWithCLLocationCoordinate2d:placeMark.location.coordinatetitle:placeMark.locality subTitle:[NSStringstringWithFormat:@"%@-%@",placeMark.country,placeMark.administrativeArea]];
086
087[_mapViewaddAnnotation:annotationView];
088
089[_mapViewselectAnnotation:annotationView animated:YES];
090
091
092NSLog(@"country:%@,locality:%@,%@,%@",placeMark.country,placeMark.locality,placeMark.administrativeArea,placeMark.region);
093
094[indicatorViewstopAnimating];
095
096}];

  

爱华网本文地址 » http://www.aihuau.com/a/25101015/261204.html

更多阅读

2013年卡盟平台排行榜,前十名--惠民卡盟 惠民卡盟平台登录

随着中国经济的发展,中国电子商务的突破,将会有越来越多的大学生,社会精英选择网络自主创业,在这些自主创业项目中,网络充值业务继服装行业之后,成为最易上手、最易赚钱的创业项目,正因如此许多点卡批发平台(卡盟平台)得到了充分的发展!很多点

声明:《ios通过经纬度定位城市,通过城市名定位经纬度 ios定位获取经纬度》为网友温暖手心的少年分享!如侵犯到您的合法权益请联系我们删除