moving a map overlay - iphone

I am trying to create an app where the user can mark an area on a map. I want him to be able to move the area he marked.
I found that there is an api for adding overlays on a map, but I cannot get to move those overlays once I put them on the map. I tried to subclass the MKCircleView with my own view and implement the touchesBegan:withEvent: method but it never seems to get called.
Any ideas how this can be implemented and why it doesn't work this way?
Thanks.

Try looking through the apple developer code for sample called Regions.
It has circles which can be dragged and moved around.

Related

Custom Map View

Here is the scenario...
I have a image of a map in jpeg format... I want to add it to my iPhone application and mark the coordinates in certain places (just like annotation in map kit ) and also when i move from one place to another place the current location should change and the new location should be marked in the image.
Is that possible ? How to achieve this instead of using the mkmapview ?
I found this tutorial how to add custom google maps, maybe you could use your image (.jpeg) as a overlay.
stiern.com/tutorials/adding-custom-google-maps-to-your-website
Sounds like you want to use an MKOverlay.
Essentially it boils down to looking at the TileMap sample code from WWDC 2010. It'll still load the Google Map in the background and your map over the top

OpenStreetMap/iOS: Markers and Routes Don't Work Together

I am a newbie to OpenStreetMap, but have a fair amount of iOS development experience. I'm working on an app that will have an OpenStreetMap map on it, with markers that respond to a touch, and a route generated programmatically from an array of locations. I can make all the pieces work, but together: not so good.
Following examples, I put the markers on the map, and hook the mapView to a delegate, so I can respond to touches on the markers. Then, again following examples, I create a CMRoute and add it as a sublayer ([mapView.contents.overlay addSublayer:walkRoute.path];). Doing that essentially hides the markers under the route sublayer; they no longer respond to a touch.
Can anyone point me in a direction that will give me the means to have a mapView and a route sublayer and still be able to detect marker touches? I don't ask for code (though that would be nice) but thoughts on how this could be accomplished.
Thanks

How to add overlays designed by user on button click in a map

I am interested in adding an option to my GIS Map application, the ability to draw Polygon, circle, polyroutes overlays for the user to search data within.The problem is that I've read and tested codes of how to draw an overlay, but they are always static.I want it to be dynamic, with dynamic center and points (or radius) set by the user on click.A mystery for me.(I'm a beginner in iPhone programming, this is my first app.)And I'm not using and don't want to use things like ArcGIS API for iPhone.I would appreciate any help.
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.
See my answer to User creating a box on MKMapView 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.
For implementing a button in an annotation view (if you want a "Remove Corner" button on the annotations), see my answer to How to get click event from a button added over MKAnnotationView.
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.
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.
The Apple sample app Breadcrumb 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.
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 How to determine if an annotation is inside of MKPolygonView (iOS).

drawing routes view in iphone

how can i draw routes on a map. This is easily solved though by placing a custom UIView over the map that acts as the map delegate but didn't how can i do this, and how to take a series of CLLocation coordinates and plot them on the map, regardless of the location the user pans to or how far they have zoomed in.Give some hint to solve this or give some sample code to do this
thanks in advance
In ios4 apple has made some nice additions for this. Look at mkoverlay protocol and mkoverlayview.
You'll find an example here
http://spitzkoff.com/craig/?p=136

MKMapView tile-based overlay

I want to draw a tile-based overlay on top of a MKMapView, but there's no obvious way to do this.
This appears to be tricky since you can zoom to any level with MKMapView (unlike Google Maps).
Has anyone attempted to do this?
Incase this question is still getting views readers should check out the HazardMap and TileMap demo code from WWDC2010.
I'm working on a game where I need to overlay objects on the map and have them scroll and zoom with the map.
Using annotation views I've been able to solve the first problem and partially solve the second problem. Annotations automatically move with the map. For scaling them, I use the mapView:regionDidChangeAnimated: delegate method to resize my annotations after a zoom event. The problem is that the annotations don't rescale until after the zoom gesture is complete.
I can think of two approaches other than filing a bug with Apple requesting that they provide an API for map overlays:
Put a (mostly invisible) view over the top of the MKMapView that intercepts zoom and scroll events, handles them, and passes them on to the map view.
Customize the open-source RouteMe library with tiles from Open Street Map or CloudMade (the former is slow, the latter costs money). But it's fully open source so you should be able to do overlays to your heart's content. You could also run your own tile server that does the tile overlays on the server.
Something I discovered later:
http://www.gisnotes.com/wordpress/2009/10/iphone-devnote-14-drawing-a-point-line-polygon-on-top-of-mkmapview/
Not quite a tile-based solution, but interesting nonetheless.