olivier
olivier

Reputation: 2645

Custom icon for location.Possible?

After much googling I'm nothing has come to my specific problem.

Is it possible to change the icon of the blue location dot with the circle? I would like to replace the locator icon with my own icon.

Then save it to a different view with my own image.By pressing a button.Like a Annotation. The result would be the location in the "AddPlace"View should store the location in a different View.

I use the MapKit Framework.

Upvotes: 1

Views: 168

Answers (1)

Vojtech Vrbka
Vojtech Vrbka

Reputation: 5368

Yes, there is delegate method of MKMapView - viewForAnnotation, which is called also for the location pin. When annotation is kind of class MKUserLocation

Example:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
    if ([annotation isKindOfClass:[MKUserLocation class]]) {
        MKAnnotationView *pinView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"pinViewLocation"];
        if (!pinView) {
            pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pinViewLocation"];
            pinView.canShowCallout = NO;
            pinView.image = [UIImage imageNamed:@"map-location-pin"];
        }
    }
    .....

Upvotes: 1

Related Questions