iOS で MapViews を始めたばかりで、継続的に移動する車を青い点として表示したいと考えています。これは地図注釈と見なされますか?
1 に答える
2
はい。例として、 Simulator Debug > Location > City Bike Ride をチェックしてください。サンフランシスコ(?)をぐるりと一周します。
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
ますが、実装は異なる場合があります。
于 2012-05-02T20:59:59.383 に答える