iosobjective-cmapkitmapkitannotation

How to remove map Places and annotations from MKMapKit in Objective c


Hi i have an MapView in My Project i need to remove all the labels Annotations, places from MapView. Looks like Plain mapView

i tried the Following Code its working fine but still i getting some building details, Street names and all i want that also to be removed only User Location Can be Visible

here is the code:

[mapView setShowsPointsOfInterest:NO];

the above code working fine and removed default location icons from mapKit but not removing all Icons and Label, how to remove all default icons and label names from MapKit


Solution

  • starting with iOS 11, you can set

    mapView.mapType = .mutedStandard
    

    This removes distracting details from the map.

    Apple uses this type of map, when they want to emphasise a transit route and everything else should be in the background without distracting.

    Starting with iOS 13 you have even more fine grained control:

    Using MKMapKit.pointOfInterestFilter you can include or exclude specific categories of points of interest.

    So if you're making an App 'Best restaurants in my city', your app has its own restaurant annotations, you remove the restaurant category from Apple's point of interests, but all other POI categories are just fine for you.

    https://developer.apple.com/documentation/mapkit/mkmapview/3143417-pointofinterestfilter?language=objc

    Starting with iOS 16 most APIs described above are deprecated, but the ideas remain the same.

    Now you set MKMapView.preferredConfiguration to a subclass of class MKMapConfiguration. These subclasses are

    Each of these classes have exactly those parameters that make sense for the type of map.

    For example, MKImageryMapConfiguration shows no POIS and no roads, so it makes no sense that this class has parameters like pointOfInterestFilter or showsTraffic.

    Classes MKStandardMapConfiguration and MKHybridMapConfiguration now have a parameter pointOfInterestFilter that has been in MKMapKit.pointOfInterestFilter in earlier iOS versions.

    Old deprecated mapView.mapType = .mutedStandard is now init parameter emphasisStyle of class MKStandardMapConfiguration

    P.S. Please also have a look at the other answer of @Grimxn. Bringing your own overlay is much effort but a valid alternative.