0

I have an app that I want the user to be able to dray a box around a location, say a parking lot. I can't figure out a good way to let them draw this. I can track a long press, and draw the MKPolygon from the touch points, but I would like them to be able to trace the parking lot, and then get the coordinate values for the corners.

I have no idea how to do this, and any help would be appreciated.

SkylarSch
  • 389
  • 2
  • 9

1 Answers1

1

A slightly different and probably easier approach you can try is to let the user specify the corners using draggable annotations.

To start "drawing", place two (or more) annotations to represent the corners of the box. Be sure to use an annotation class that implements setCoordinate: so it's draggable.

The user can drag the corners where they want and tap some button when done at which point you can create the MKPolygon using the annotation coordinates and then remove the annotations.

Or, you can re-create the MKPolygon every time the user finishes dragging an annotation (corner) and the user taps some button to say "done" and then you can remove the annotations.

  • I like the idea, but I still want the user to just trace their selection. While your idea is probably going to be how I have to do it. I'll mark your answer as accepted if I can't find a way to do what I want. Thanks for your input, I really appreciate it. – SkylarSch Aug 04 '11 at 14:09
  • 1
    What I ended up doing is sliding in an extra UIView with a clear color. Added a sub view the user could resize and move around, then when they hit 'Save' it pulls the corner points from the 'resize view' and maps them the coordinates of the map view. – SkylarSch Aug 13 '11 at 23:31