Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw a circle on mapView

I am developing an application in which I have to show a mapView. What I exactly want to do is when user click on radius button, there should be circle drawn of that radius with the center point as the current location. Please tell me how can I draw a filled circle on my map that indicate the radius from the current location.

Any help will be highly appreciated Thanks in advance!!

like image 919
Gypsa Avatar asked Dec 13 '22 11:12

Gypsa


2 Answers

Create a new instance of MKCircle with appropriate center and radius, and then add it to the map view's overlays. MKCircle in a subclass of MKOverlay, so you can handle it like any other overlay. Example:

MKCircle *myCircle = [MKCircle circleWithCenterCoordinate:myCenterPoint radius:myRadius];
[myMapView addOverlay:myCircle];

I'll leave it to you to substitute "current location" and user-selected radius for myCenterPoint and myRadius in the code above.

like image 119
Caleb Avatar answered Dec 28 '22 02:12

Caleb


If you want to draw anything on a map your best friend is MKOverlay.. Search in Google for MKOverlay tutorials.

MKCircle is the Class which you want to know about. Just read the docs to get to know some idea

Just see circleWithCenterCoordinate:radius

like image 32
ipraba Avatar answered Dec 28 '22 02:12

ipraba