i am working on a map app with some overlays (annotations, circles, polygons). And i also have UISwitches to appear/disappear them. For the annotation is easy: .add / .remove, it works.
@IBAction func airportLayerSwitch(_ sender: UISwitch) {
if sender.isOn {
mapView.addAnnotations(airports)
} else {
mapView.removeAnnotations(airports)
}
}
but for the circles, polygons I can not make them disappear. Here is my func for the circle:
func airportBoundryOverlay(airportName:String, radius:CLLocationDistance){
for airport in airports {
if airport.title == airportName{
let center = airport.coordinate
let circle = MKCircle(center: center, radius: radius)
mapView.addOverlay(circle)
}
}
}
func airportBoundries() {
airportBoundryOverlay(airportName: "Békéscsaba",radius: 4000)
airportBoundryOverlay(airportName: "Budaörs",radius: 4000)
}
so for my second UISwitch:
@IBAction func tizLayerSwitch(_ sender: UISwitch) {
if sender.isOn {
airportBoundries()
} else {
// TODO: ??????? disappear airportBoundries() ??????
}
}
when I turn the UISwitch on, the circles appear, but I cannot make them disappear.