Search code examples
iosobjective-cmapkitmapkitannotation

How to change proximity of user location annotation


How to change the proximity of which a userLocation annotation generates. enter image description here
I'm talking about the faded blue circle the userLocation annotation is creating around it. How can I change it's radius?


Solution

  • Take a look at: https://github.com/TransitApp/SVPulsingAnnotationView

    Add following files from Library:

    SVAnnotation.h
    SVAnnotation.m
    
    SVPulsingAnnotationView.h
    SVPulsingAnnotationView.m
    

    Import:

    #import "SVAnnotation.h"
    #import "SVPulsingAnnotationView.h"
    

    Using SVPulsingAnnotationView you can set pulseScaleFactor property to change radius,use below code in viewForAnnotation method when you found UserLocation:

            static NSString *identifier = @"currentLocation";
            SVPulsingAnnotationView *pulsingView = (SVPulsingAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
    
            if(pulsingView == nil) {
                pulsingView = [[SVPulsingAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
                pulsingView.annotationColor = [UIColor colorWithRed:0.678431 green:0 blue:0 alpha:1];
                pulsingView.pulseScaleFactor=7.0;//Change pulseScaleFactor as required
                pulsingView.canShowCallout = YES;
            }
    
            return pulsingView;