How to Increase the Radius of userLocation Annotation in Mapkit

前端 未结 1 1946
没有蜡笔的小新
没有蜡笔的小新 2021-01-16 05:50

My app takes user permission and move the map to the location. And at that position by default MapKit add a blue icon which is generating some pulse.
I\'v

相关标签:
1条回答
  • 2021-01-16 06:07

    Unfortunately you cannot simply alter the behaviour of the standard annotation; you need to take over display of the annotation view yourself.

    The user location is a map annotation of type MKUserLocation. If you implement the MKMapViewDelegate method viewForAnnotation and the map is displaying the user's location then the delegate method will be called with an instance of MKUserLocation - your responsibility is to either return nil, in which case the standard annotation view will be displayed, or return an instance of MKAnnotationView which will be displayed instead.

    You can code something like:

    - (MKAnnotationView *)mapView:(MKMapView *)mapView
            viewForAnnotation:(id<MKAnnotation>)annotation {
        if ([annotation isKindOfClass:[MKUserLocation class]]) {
            return [[MyPulsingViewAnnotation alloc] initWithUserLocation:annotation];
        }
    
        return nil;
    }
    

    As for performing some animation when the 'pulse' intersects another annotation, you will need to pass the other annotation locations to your pulsing view and check the coordinates when you run the animation.

    0 讨论(0)
提交回复
热议问题