我刚刚进入iOS上的MapViews,并希望将一辆不断移动的汽车显示为蓝点。这会被视为地图注记吗?
是的。例如,请查看模拟器调试>位置>城市自行车骑行。它在旧金山做一个缓慢的循环(?
收听在 Mapview 委托中实现的更新
- (void)mapView:(MKMapView *)amapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
NSLog(@"im here! - %f,%f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
}
并调整注释实现
- (MKAnnotationView *) mapView:(MKMapView *)amapView viewForAnnotation:(id <MKAnnotation>) annotation{
if ([annotation isKindOfClass:[MKUserLocation class]]) {
return nil;
}
NSLog(@"annotation = %@",((NSObject *)annotation));
MKAnnotationView *annView;
annView = [amapView dequeueReusableAnnotationViewWithIdentifier:@"currentloc"];
if(!annView)
{
annView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"] autorelease];
((MKPinAnnotationView *)annView).pinColor = MKPinAnnotationColorGreen;
((MKPinAnnotationView *)annView).animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
annView.draggable = YES;
}
return annView;
}
我输入的截图只是通过返回 nil 来使用带有精度圆圈的默认蓝点MKUserLocation
但您的实现可能有所不同。