Hi all
I developing an App using swiftui and mapkit that adds several layers to the map : Annotations, Circles and Polyline.
I'm adding the polylines the folloiwng way:
annotation.coordinate = CLLocationCoordinate2D(latitude: locations.lat, longitude: locations.lon)
let contagem = locations_map.count
let polyline = MKGeodesicPolyline(coordinates: locations_map, count: contagem )
//print(contagem)
let circle = MKCircle(center: destination, radius: locations.accuracy)
uiView.setRegion(mapRegion, animated: true)
uiView.delegate = context.coordinator
uiView.addOverlay(polyline)
uiView.addAnnotation(annotation)
uiView.addOverlay(circle)
Than when I need to remove the annotations the ciecles and the polylines I'm doing the folloiwng
uiView.removeAnnotations(uiView.annotations)
uiView.removeOverlays(uiView.overlays)
But all works except the polylines that persist in the map !!