MKMapView annotations - change pin with dot

599 views Asked by At

I have a tracing tool, which checks whether the car reaches some predefined locations.

Currently, when the car reaches location, I use MKPointAnnotation and add a pin at that location. However, I don't want pin. I want a dot.

Is there a way to achieve it? Below is the code that adds pin.

- (void) addPin:(NSArray *)locations
 {
     self.location = [locations lastObject];
     self.locationCoordinate2D = self.location.coordinate;
     MKPointAnnotation *newAnnotation = [[MKPointAnnotation alloc]init];
     newAnnotation.coordinate = self.locationCoordinate2D;
     [mapView addAnnotation:newAnnotation];
 }

Thanks in advance.

1

There are 1 answers

2
shearnonsense On

The MKUserLocationView class which provides the dot that you see for your current location cannot be initialised without using private APIs, but you may be interested in SVPulsingAnnotationView, an open-source replica of this class that you could customise to your taste.

If this is not what you are looking for, you can draw a custom annotation yourself using CoreGraphics by subclassing MKAnnotationView. Alternatively, you can use the image property of a MKAnnotationView to use a custom image for the annotation. You may also find the iOS documentation for creating custom annotations on maps useful.