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

// 通过地理编码,得到位置,

    CLLocation *loc = [[CLLocation alloc] initWithLatitude:30.662221 longitude:104.041367];

    [geoCoder reverseGeocodeLocation:loc completionHandler:^(NSArray *placemarks, NSError *error) {

        CLPlacemark *pMark = [placemarks firstObject];

        NSData *data = [NSJSONSerialization dataWithJSONObject:pMark.addressDictionary options:NSJSONWritingPrettyPrinted error:nil];

        

        NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

        NSLog(@"%@", result);

        

        MKPlacemark *mkMark = [[MKPlacemark alloc] initWithPlacemark:pMark];

//设置地图的以什么形式显示,卫星图,标准图等

        NSDictionary *options = @{MKLaunchOptionsMapTypeKey:@(MKMapTypeStandard)};

        MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:mkMark];

//调用函数,把地图显示出来。

        [mapItem openInMapsWithLaunchOptions:options];

    }];

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
  • 2021-04-03
  • 2021-08-10
  • 2021-04-30
  • 2021-06-18
  • 2021-04-20
猜你喜欢
  • 2022-01-10
  • 2022-02-15
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2021-12-07
相关资源
相似解决方案