MapKit MKCircle Change Radius on Zoom Level

1.2k views Asked by At

I'm trying to create an MKCircle overlay on a map, however I would like the size of the circle on the screen to remain constant as the user zooms.

So as the user zooms in, the radius gets smaller and as the user zooms out, the radius gets larger.

I'm working in Swift 3. Is there a specific MapKit method I should be using to accomplish this? I know there is an option to use an image of a circle as an annotation, however I want to dynamically change the color of the circle.

In other words, I want the MKCircle to scale the same way an MKPolyline scales as you zoom in and out

1

There are 1 answers

5
matt On

So as the user zooms in, the radius gets smaller and as the user zooms out, the radius gets larger

An MKCircle would presumably be part of an overlay (MKOverlay). An overlay works by simulating drawing on the earth itself. Thus, the drawing changes with the zoom level.

So if you don't want that to happen, don't use an MKOverlay. You could, for example, just make a normal view that displays a circle and lay it in front of the map view. Or you could use an annotation instead (MKAnnotation); an annotation's image does not change size as the map is zoomed.