Remove polyline layer before presenting a new one

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.

Code Block    
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)
}


I am not able to reproduce the issue you are describing using the code you posted and the bare minimum to display a polyline in an MKMapView.

Could you please try with the latest iOS 15 beta build and if the issue still persists please file a report via Feedback Assistant (https://feedbackassistant.apple.com/) and make sure you include a runnable sample project that demonstrates the issue. 

Remove polyline layer before presenting a new one
 
 
Q