探索MapKit:构建地图应用的实用指南
1. 地图标注与反向地理编码
在处理地图标注时,我们需要确保地图视图委托仅处理我们已知的标注类型。例如,地图视图不仅会通知我们自定义的标注,还会处理像 MKUserLocation 这样的系统标注。当开启用户跟踪功能时,每次需要显示用户位置,委托方法都会被调用。对于不认识的标注,我们的方法应返回 nil ,让地图视图自行处理。
if ([annotation isKindOfClass:[MapLocation class]]) {
MKPinAnnotationView *annotationView = (MKPinAnnotationView *)[theMapView
dequeueReusableAnnotationViewWithIdentifier:placemarkIdentifier];
if (annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:placemarkIdentifier];
}
else
annotationView.annotation = annotation;
return annotationView;
}
return nil;
反向
超级会员免费看
订阅专栏 解锁全文
55

被折叠的 条评论
为什么被折叠?



