I am adding a custom annotation instead of the pin annotation. Basically, I draw a circle in these annotations and add them to the map. THe problem these custom annotations obscure the user location view ( the blue dot) How do I bring the blue dot to the front.
- (void)mapView:(MKMapView *)mapView
didUpdateUserLocation:(MKUserLocation *)userLocation
{
UIView *user = [mapView viewForAnnotation:userLocation];
[mapView bringSubviewToFront:user];
}
However, this is not working for me. The blue user dot is still being covered by my custom annotations. Any ideas how I can get the user location view to appear in front? Cheers
Try this, it works.:
MKAnnotationView *userLocationView = [self.mapView viewForAnnotation:self.mapView.userLocation]; [userLocationView.superview bringSubviewToFront:userLocationView];
I accomplished it like this:
- (void) mapView:(MKMapView *)aMapView didAddAnnotationViews:(NSArray *)views {
for (MKAnnotationView *view in views) {
if ([[view annotation] isKindOfClass:[MKUserLocation class]]) {
[[view superview] bringSubviewToFront:view];
} else {
[[view superview] sendSubviewToBack:view];
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With