在地理编码器字符串中显示当前位置的最佳方法是什么!! 而不是“当前位置”;
以下代码仅适用于第一次!如果位置发生变化,那么它将不会更新位置。
- (MKAnnotationView *) mapView: (MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>) annotation{
if (annotation == mapView.userLocation){
[self.geocoder reverseGeocodeLocation:self.brokendownMapview.userLocation.location completionHandler:^(NSArray *placemarks, NSError *error) {
if ((placemarks != nil) && (placemarks.count > 0)) {
// If the placemark is not nil then we have at least one placemark. Typically there will only be one.
_placemark = [placemarks objectAtIndex:0];
// we have received our current location, so enable the "Get Current Address" button
CLS_LOG(@"What is location %@",_placemark);
_currentLocation.text = [NSString stringWithFormat:@"%@",_placemark];
NSString *locationName =[NSString stringWithFormat:@"%@",_placemark.name];
self.myMapView.userLocation.title =locationName;
NSString *localityAndPostcode =[NSString stringWithFormat:@"%@,%@",_placemark.locality,_placemark.postalCode];
self.myMapView.userLocation.subtitle = localityAndPostcode;
}
else {
// Handle the nil case if necessary.
self.myMapView.userLocation.title =@"Location is unknown";
self.myMapView.userLocation.subtitle =@"";
}
}];
return nil;
}