Warve
Warve

Reputation: 511

swift MKPolyLineRenderer intersect issue

I'm rendering a bunch of lines on a map that are having an issue when one line goes over another resulting in a merge. I'm using a custom renderer which sets the width and colors etc inside the func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer method. How can I prevent the merge of the MKPolyLines

Here's an image detailing the "merge" issue.

Merge issue on route

final class RouteRenderer: MKPolylineRenderer {
    
    override func strokePath(_ path: CGPath, in context: CGContext) {
        guard let overlayColor = self.overlay as? RouteLine, let color = overlayColor.color else {
            super.strokePath(path, in: context)
            return
        }
        context.saveGState()
        context.setStrokeColor(color.cgColor)
        context.addPath(path)
        context.drawPath(using: .stroke)
        context.restoreGState()
    }
    
}

Note I'm storing the lines as an array of [MKPolylines] in an attempt to solve the issue but I think that partly solved it, the issue I think is with the renderer.

Upvotes: 0

Views: 58

Answers (0)

Related Questions