I have replaced the blue dot for user location in mapview
with my custom annotation view, How can I make my custom annotation to follow user's location like the default blue dot does? When I replace the blue dot with my custom annotation or simply create MKAnnoationView
, it just stops moving with the user. In viewForAnnotation
delegate method of mapview , I am doing
pinView = [[MKAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:defaultPinID];
pinView.image = [UIImage imageNamed:@"newgreen2.png"];
[mapView.userLocation setTitle:@"I am here"];
return pinView
This is showing a pin with newgreen2 image but it does not move, but if I return nil in this delegate method, blue dot appears by default which moves with user's location. Is there any trick to mimic this behavior of default blue dot for user location for my custom annotation view? I have noticed that viewForAnnotation
is called only once and then blue dot automatically starts tracing the users location.
Is there any way by which I can tell my annotation view to follow the user's location?
We have two links that could be helpful here
How to change MKMapView's user-location blue dot to an image of choice?
And
Avoid flicker when moving annotations in a MKMapView on iPhone
Please check it out.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.