Hi, I use polylines, and tested it with IOS 13.5 - 14.3 to display my routes on the map. If I want to show a new route I delete the previous route. The polyline has then disappeared from the map, but as soon as a new route is drawn, the old route reappears and is visible together with the new route. It is not possible to really remove a polyline or overlay. I tried several solutions that I found all over, but nothings works.
I can't continue developing my app because of this bug.
I hope you Apple can help me out.
func drawPolyline(with coordinates: [CLLocationCoordinate2D], isNeedToCenter: Bool = false, animated: Bool = false) {
// Get the all overlays from map view
if let overlays = mapView?.overlays {
for overlay in overlays {
// remove all MKPolyline-Overlays
if overlay is MKPolyline {
print("Found it")
mapView?.removeOverlay(overlay)
}
}
}
polylineRoute = MKPolyline(coordinates: coordinates, count: coordinates.count)
self.mapView.addOverlay(polylineRoute)
}
1
0
1.2k