Change MKMapType in MKMapView and save custom pinImage for annotations

I set a custom pinImage for my annotations, and when I change the type to MKMapTypeHybrid, it returns the pinImage setting to the standard pins.

I install mapType in my viewWillAppearmap display controller method . I set my pinImage for annotations like this (shortened for clarity):

- (MKAnnotationView *) mapView:(MKMapView *) mapView viewForAnnotation:(id ) annotation {

    MKPinAnnotationView *customAnnotationView=[[[MKPinAnnotationView alloc] 
                                            initWithAnnotation:annotation 
                                            reuseIdentifier:@"markerAnnotationView"] autorelease];
    UIImage *pinImage = [UIImage imageNamed:@"/pin-image"];
    [customAnnotationView setImage:pinImage];
    return customAnnotationView;
}

Is it possible to use setImageand install mapType through code?

+3
source share
1 answer

MKAnnotationView MKPinAnnotationView. MKPinAnnotationView , , MKAnnotationView.

, , , . , MKPinAnnotationView setImage, , mapTypes. , , . .

+9

Source: https://habr.com/ru/post/1795116/


All Articles