美文网首页
地图地理编码(逆向)

地图地理编码(逆向)

作者: 只因为趁年轻 | 来源:发表于2017-09-05 15:20 被阅读79次
1.百度地图定位
  • 需要调用代理方法设置 - (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation , 从代理方法里获取当前最新的location.
  • 创建BMKGeoCodeSearch进行反地理编码,记得挂代理<BMKGeoCodeSearchDelegate>
    self.getCodeSearch = [[BMKGeoCodeSearch alloc] init];
    self.getCodeSearch.delegate = self;
    //1.创建反向地理编码选项对象
    BMKReverseGeoCodeOption *reverseOption=[[BMKReverseGeoCodeOption alloc]init];
    //2.给反向地理编码选项对象的坐标点赋值
    reverseOption.reverseGeoPoint=userLocation.location.coordinate;
    //3.执行反地理编码
    [self.getCodeSearch reverseGeoCode:reverseOption];
  • 执行代理方法,获取反地理编码
-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
{
    BMKAddressComponent *component=[[BMKAddressComponent alloc]init];
    component=result.addressDetail;
    [self.locationBtn setTitle:[NSString stringWithFormat:@"%@%@", component.streetName?:@"", component.streetNumber?:@""] forState:0];
}
  • 补充说明
    使用对应的地图获取出来的经纬度,只能使用对应的正向/反向地理编码进行解析, 以上是百度地图解析地理编码的方法
2.系统自带方法

1.设置参数

- (void)reveLocation
{
//定位初始化
    CLLocationManager * locationManager=[[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.distanceFilter = 10;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [locationManager requestWhenInUseAuthorization];
    [locationManager startUpdatingLocation];
}

2.实现回调,执行代理方法

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    //此处locations存储了持续更新的位置坐标值,取最后一个值为最新位置,如果不想让其持续更新位置,则在此方法中获取到一个值之后让locationManager stopUpdatingLocation
    CLLocation *currentLocation = [locations lastObject];
    // 获取当前所在的城市名
    CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    //根据经纬度反向地理编译出地址信息
    [geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *array, NSError *error)
     {
         if (!error)
         {
             CLPlacemark *place = array.lastObject;
             _locationName = place.name;
         }
         else
         {
         }
     }];
}
3.高德地图

1.设置参数,进行逆地理

- (void)searchReGeocode
  
{
  
  AMapReGeocodeSearchRequest *regeoRequest  = [[AMapReGeocodeSearchRequest alloc] init];
  
  regeoRequest.searchType =  AMapSearchType_ReGeocode;
  
  regeoRequest.location =  [AMapGeoPoint locationWithLatitude:39.990459 longtitude:116.481476];
  
  regeoRequest.radius = 10000;
  
  regeoRequest.requireExtension  = YES;
  
  [self.search  AMapReGoecodeSearch: regeoRequest];
  
}

2.实现回调,获取查询结果:

-  (void)onReGeocodeSearchDone:(AMapReGeocodeSearchRequest *)request  response:(AMapReGeocodeSearchResponse *)response
  
{
  
  NSString *result = [NSString stringWithFormat:@"ReGeocode:  %@", response.regeocode];
  
  NSLog(@"ReGeo: %@",  result);
  
}

相关文章

  • 地图地理编码(逆向)

    1.百度地图定位 需要调用代理方法设置 - (void)didUpdateBMKUserLocation:(BMK...

  • 高德地图正/逆向地理编码

    应该场景描述:后台返回给我的地址,我需要将地址转成 经纬度,进行导航。记录原因:网上相关文档,因为版本原因,更新不...

  • 全球逆地理编码办法

    1. 百度地图 有全球逆地理编码,但18年改版后国外逆地理编码只有服务端api可用 逆地理编码[https://l...

  • 苹果地图 地理编码 反地理编码

    CoreLocation.framework 要用到这个框架 import

  • Swift 使用系统地图导航

    地理编码 //设置好地图参数,以及出发点和结束地点

  • iOS谷歌地图集成

    最近项目中用到了谷歌地图,主要用于谷歌地图显示,标记,地理位置反编码,地理位置补全搜索等等,这是谷歌地图的官方AP...

  • 对 'CoreLocation' say so

    应用场景 定位 地图CoreLocation : 用于地理定位, 地理编码, 区域监听等(着重功能实现)MapKi...

  • MapView演练

    结合MapView与LBS相关知识点:定位、地理编码/反地理编码、地图覆盖物、导航写了一个小的Demo 并且在导航...

  • 地理编码与反编码

    首先我们要了解地理编码和反编码的含义和作用:<1>地理编码:把地名转换成位置信息作用:把文字描述的 位置转换成地图...

  • 定位和地图功能简介

    CoreLocation:用于地理定位,地理编码,区域监听等(着重功能实现)MapKit:用于地图展示,如大头针,...

网友评论

      本文标题:地图地理编码(逆向)

      本文链接:https://www.haomeiwen.com/subject/ytbujxtx.html