How to represent a constantly moving signal on MapView?

I just enter MapViews on iOS and want to show a car constantly moving like a blue dot. Will this be considered as an abstract map?

+3
source share
1 answer

Yes. For an example, check out the Simulator Debug> Location> City Bike Ride section. This is a slow cycle around San Francisco (?)

To listen to updates in your Mapview business

- (void)mapView:(MKMapView *)amapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    NSLog(@"im here! - %f,%f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude); 


}

and set up annotation tool

- (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;
}

The snipe I installed just comes with a default blue dot with a circle of precision, returning nil for MKUserLocation, but your implementation may be different.

+2
source

All Articles