位置与地图:几种位置反编码方式

来源:互联网 发布:知乎 宋仲基宋慧乔 编辑:程序博客网 时间:2024/06/04 19:18

  • 位置反编码的本概念
  • 位置的编码就是将经纬度转换为具体的位置信息
  • ios5.0之后使用CLGeocoder类,用于反编码处理;ios5之前则使用MKReverseGeoCoder类进行反编码处理
1.CLGeocoder位置反编码
  //-------------------CLGeocoder位置反编码 - 5.0之后使用-------------------------        CLGeocoder *geocoder = [[CLGeocoder alloc]init];    [geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) {        //遍历位置信息        for (CLPlacemark * place in placemarks) {            NSLog(@"name,%@",place.name);  //位置名称            NSLog(@"thoroughfare,%@",place.thoroughfare);//街道            NSLog( @"subThoroughfare,%@",place.subThoroughfare);//子街道            NSLog(@"locality,%@",place.locality);//市            NSLog(@"subLocality,%@",place.subLocality);//区            NSLog(@"country,%@",place.country);//国家        }    }];//CLGeocoder的反编码}

2.GOOGLE API反编码

A:接口地址
http://maps.googleapis.com/maps/api/geocode/json?latlng = 39.90424,116.34532&sensor=ture
0 0
原创粉丝点击