Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To let the user "draw" an arbitrary polygon on the map, one approach is to use draggable annotations that represent the corners of the polygon. Provide an "Add Corner" button and some kind of Remove Corner button on each annotation. </p> <p>See my answer to <a href="https://stackoverflow.com/questions/6931058/user-creating-a-box-on-mkmapview/6931464#6931464">User creating a box on MKMapView</a> for some more details. On that question though, the OP actually ended up using another solution described in the comments which would work well if the polygons are always rectangles.</p> <p>For implementing a button in an annotation view (if you want a "Remove Corner" button on the annotations), see my answer to <a href="https://stackoverflow.com/questions/6941199/how-to-get-click-event-from-a-button-added-over-mkannotationview/6942854#6942854">How to get click event from a button added over MKAnnotationView</a>.</p> <p>Once you a have a polygon or other overlay on the map, dragging it by direct touches may only be possible by adding a gesture recognizer to the map (with its own scrolling turned off) and using a custom MKOverlay and MKOverlayView that allow coordinate changes. Adding a gesture recognizer directly to an MKOverlayView doesn't seem to work and the built-in overlay classes don't allow changes to coordinates.</p> <p>An alternative to moving by direct touches is putting some controls on the side (Up/Down/Left/Right/etc buttons) that modify the custom overlay.</p> <p>The Apple sample app <a href="http://developer.apple.com/library/ios/#samplecode/Breadcrumb/Introduction/Intro.html" rel="nofollow noreferrer">Breadcrumb</a> gives an example of a custom overlay/view for a path. In WWDC 2010, the sample app LocationReminders gives an example of a custom overlay/view for a circle that can move and resize.</p> <p>Finally, when you do a search for businesses, you could use the overlay's boundingMapRect (which is always a rectangle regardless of the overlay's shape) as the bounding box for the initial search and then check if the coordinate of each business found is in the overlay's actual shape using the answer to <a href="https://stackoverflow.com/questions/4354130/how-to-determine-if-an-annotation-is-inside-of-mkpolygonview-ios/4354250#4354250">How to determine if an annotation is inside of MKPolygonView (iOS)</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload