【问题标题】:How to get current location of MapView in NSLog?如何在 NSLog 中获取 MapView 的当前位置?
【发布时间】:2012-09-21 11:03:41
【问题描述】:

我可以获取用户当前位置的经度和高度,但不能获取 location 的名称。我使用 userLocation 属性如下:

NSLog(@"Current location=%@",mapView.userLocation);

但是,它给了我输出 Current location=<MKUserLocation: 0x1f59e8c0>

我想获取该位置的字符串值,而不是 0x1f59e8c0。如何做到这一点?

【问题讨论】:

    标签: objective-c mkmapview currentlocation


    【解决方案1】:

    从 MKMapView 文档开始:http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html

    您可以沿着链条向下查找经度是 CLLocationCoordinate2D 的一部分(并且是双精度) http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CoreLocationDataTypesRef/Reference/reference.html#//apple_ref/doc/c_ref/CLLocationCoordinate2D

    NSLog(@"Current longitude = %f",mapView.userLocation.location.coordinate.longitude); 
    

    【讨论】:

      【解决方案2】:
      NSLog(@"Current location %@",mapView.userLocation.title); 
      

      附:还有更多属性副标题

      【讨论】:

      • 但是,这给了我价值,当前位置=当前位置
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多