Search code examples
iosfilterannotationsmapkitandroid-mapview

How to filter annotations on a map view


I'm currently working on an application that displays annotations on the map. They have multiple colours that represent different things. For example green represents cafes and Purple is to represent museums. I would like to be able to have a button that filters the annotations so that all the purple show whilst the other colours stay hidden and vice versa.

Thanks in advance, Niall.


Solution

  • MKAnnotationView, being a subclass of UIView, has a hidden property. Just filter your mapView.annotations based on the UI and apply a true value to that property.