Heestand XYZ
Heestand XYZ

Reputation: 2231

MKOverlay not appearing until MKMapView is zoomed or moved?

So I got an MKCirlce (MKOverlay), and I've added it like this:

self.current_location_overlay = MKCircle(center: self.current_location!, radius: 200)
self.mk_map_view.add(self.current_location_overlay!)

I've set the map delegate and added this MKMapViewDelegate method:

func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
    if let overlay = overlay as? MKCircle {
        let circle_renderer = MKCircleRenderer(circle: overlay)
        circle_renderer.fillColor = UIColor.red.withAlphaComponent(0.2)
        circle_renderer.setNeedsDisplay()
        return circle_renderer
    } else {
        return MKOverlayRenderer(overlay: overlay)
    }
}

Tho the overlay is not appearing at start, only after panning or zooming the map it appears.

Seems like others have had this problem, tho no solution on this post seems to help.

Dose anyone know how to solve this?

Upvotes: 0

Views: 401

Answers (0)

Related Questions