Reputation: 161
I'd like to allow users to mark some area on map. This area should be any closed shape. For instance user can draw something like this:
In next step I'd like to calculate region of this shape. How can I achive this?
Upvotes: 1
Views: 459
Reputation: 1440
You can use MKPolygon
.
First of all you'll need to disable user interaction on the map view so that it won't move around while you're trying to draw on it. Next up you can use the UIResponder
functions touchesBegan
, touchesMoved
and touchesEnded
. As you move through these three functions you can record the points the user has pressed. Lastly you can then create an MKPolygon from this array of points that you have recorded.
Upvotes: 1