objective-c – 如何在地图工具包中显示默认用户位置和自定义的年度视图?

前端之家收集整理的这篇文章主要介绍了objective-c – 如何在地图工具包中显示默认用户位置和自定义的年度视图?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用地图工具包并显示自定义注释视图.一个是car Image,另一个是user Image(作为用户的当前位置).现在我想显示map kit提供的当前用户位置默认值.但是无法显示它.如何在地图套件中显示我的车的蓝色圆圈?

解决方法

显示用户位置,请在地图视图对象上将以下属性设置为true

mapView.showsUserLocation = YES;

显示自定义注释,请在地图视图注记上设置图像属性

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation 
{
// check for nil annotation,dequeue / reuse annotation
// to avoid over riding the user location default image ( blue dot )

if ( mapView.UserLocation == annotation ) {

return nil; // display default image

}

MKAnnotationView* pin = (MKAnnotationView*)
[mapView dequeueReusableAnnotationViewWithIdentifier: PIN_RECYCLE_ID];

if ( pin == nil ) {

pin = [(MKAnnotationView*) [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier: PIN_RECYCLE_ID] autorelease] ;

pin.canShowCallout = YES;

}
else {

[pin setAnnotation: annotation];
}

pin.image = [UIImage imageNamed:@"car-image.png"];

return pin;
}

猜你在找的Xcode相关文章