iOS开发之CLPlacemark属性一览(定位编码与反编码相关)

注意

1.四大直辖市的城市信息无法通过CLPlacemark的locality属性获得,只能通过访问administrativeArea属性来获得(如果locality为空,则可知为直辖市),代码参考如下

  NSString *city = placemark.locality;

     if (!city) {

           //四大直辖市的城市信息无法通过locality获得,只能通过获取省份的方法来获得(如果city为空,则可知为直辖市)

          city = placemark.administrativeArea;

     }

 

2.上面的FormattedAddressLines可通过以下方法输出:

  NSArray *lines = _placemark.addressDictionary[@"FormattedAddressLines"];

  NSString *addressString = [lines componentsJoinedByString:@"\n"];

  NSLog(@"Address: %@", addressString);

 

3.星号表示addressDictionary里面可能没有这个键和值

相关文章:

  • 2021-10-24
  • 2021-04-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2021-09-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
相关资源
相似解决方案