I'm working on a project that uses MKMapView
and requires quite a few overlays, and ran into some odd behaviour while rendering the overlays onto the map.
The delegate method is quite standard:
func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer {
guard let line = overlay as? MKPolyline else { return MKOverlayRenderer() }
let renderer = MKPolylineRenderer(polyline: line)
renderer.lineWidth = 5
renderer.alpha = 1
renderer.strokeColor = UIColor.redColor()
return renderer
}
But, for some reason, when scrolling the map roughly around the longitudes 180°W to 140°W most or all vertical MKPolyline
s between those longitudes disappear. And they only disappear on certain zoom levels, and only in this area.
How it looks when positioned in a specific way:
How it looks after zooming out a tiny bit:
In total I'm rendering 107 MKPolyline
s, all of which consist of only two points.
If anybody has experienced similar behaviour while working with overlays and found a solution, I'd very much appreciate some insight on this.