For my next project I have an image of a small village and I have to turn this into a map.
In this map I have to be able to add MKAnnotationView like the "normal" MapKit Map. The user can also zoom the map. I'm just trying to figure out how to implement this custom map: The only possible way is to create a UIImageView as subviews to which I add the "reproductions" of MKAnnotationView?
Any suggestions on how I can create this type of map?
Also have a look at MapBox. There are two options:
MapBox iOS SDK - works like MapKit, but is an open source alternative that lets you do completely custom maps (iOS 5+).
MBXMapKit - built on MapKit, but allows custom map tiles (iOS 7+).
I don't think using a UIImageView will work particularly well. If the suggested source code doesn't work for you, look at the documentation and sample code for CATiledLayer.
Related
Wondering if its possible to show iOS map types with the MapBox iOS SDK.
I.E. if I use and MKMapView I can select from standard, satellite and hybrid iOS map types. I would also like to add Open Street Map as an option. Of course I cannot user MKMapView to do that. I can use RMMapView to show an OSM map, but can it show an iOS map?
Biggest reason for this is I would like to stick with one interface. I.E. if I add a bunch of markers to my MKMapView and the user switches to the RMMapView I would have to create RM markers and add them to the RMMapView. This creates a nighrmare when the user creates markers on the different maps and then switches back and forth.
You can't show an "iOS map", which is really an MKMapView, inside of Route-Me/Mapbox. They are designed as peers not meant to be used together.
I want to get image of any location and use this image for showing a view. I will look like a MKMapView but it's faster (I think so)
For Google Map, there is api to do : https://developers.google.com/maps/documentation/staticmaps/
But what about map of iOS? Can you help me?
--UPDATE--
Solution: MKMapSnapshotter
Under iOS7 you can use MKMapSnapshotter to asynchronously generate MKMapSnapshot objects which you can ask for their UIImage representation.
Otherwise your best option is to use a MKMapView and to set userInteractionEnabled to NO.
Alternatively Google Maps provides a static maps API.
IN my project I need to draw a route between two pins. Can anyone tell me what are the methods used. And give me the example code for that.
Try these posts.. It will help you i think
http://navarra.ca/?p=786
http://spitzkoff.com/craig/?p=108
This will automatically use Google Direction API and will fetch the points in between the locations i guess..
Anyhow see this blog http://laurilarjo.wordpress.com/2010/10/23/using-google-directions-api-and-drawing-routes-in-iphone-mkmapview/
You can use MKPolyLineView - it allows you to draw a line (or polyline, if you need several segments) as an overlay on top of the MKMapView. Apple even has example code using this here.
Note that this method uses an MKOverlayView which was added in iOS 4, so it only works in iOS 4+. If you need to target iOS 3 devices, then you can use the MKAnnotationView hack that others have linked to (originating as far as I can tell from that spitzkoff blog post). I used to do it that way, but did away with it when iOS 4 had matured enough - I'd wholeheartedly recommend doing it the new way if you don't need iOS 3 support.
As for pins, use MKPinAnnotationView
Go to google maps. "Get directions". Make a screenshot. Then use UIImageView. This is what I would do.
Is it possible to add an overlay image on top of a map added in my app? I am using MapKit to show the map of an area. I would like to add an overlay image on top of the map before the pins show up
i.e. the stack should be map->image overlay->pins
Is it possible without going into the hierarchy of views - get all subviews of the view and then add an image just on top of the map?
Thanks.
I know that you need a solution for a static map , but here's one for a "draggable" one , which should also solve your problem.
You should subclass MKOverlayView , and override its (empty by default):
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context.
The method should actually do what drawRect does in views.
You should also implement another "should" method , that should return TRUE if the overlay should be visible on screen (in your case.. always ?).
In the overriden method , you should draw your image on top of the map (according to the mapRect and zoomScale of course) , and viola!
Some more reference :
http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html#//apple_ref/doc/uid/TP40009497-CH6-SW15
Try taking a look into the MKOverlayView outlined in the MKMapView documentation (see link). In addition, it may be worth reviewing "Apple WWDC Session 127 - Customizing Maps with Overlays".
If you watch that "Apple WWDC Session 127 - Customizing Maps with Overlays" session there is a part about about raster images as overlays. If you download the 2010 WWDC Sample Code there is an example named "TileMap" which has the code for doing that.
I want to you iPhone LocationManager and display the position using a custom map, different from the one used by MapView. Is there any way to customize the MapView or should I rebuild my own MapView from scratch ?
Do you think MapView will be open to achieve this kind of customization in a future release of the SDK ?
Do you have any recommendation to rebuild a MapView from scratch. I will have to divided my map in level and each level in tiles. But should I associate a tile with an UIImage or should I build/manage dynamically an UIImage composed of tiles currently displayed ?
Please make sure you file a bug with Apple, asking for this feature (I already have). In the meantime, I think your best bet is to take a look at the route-me library. It emulates the built-in Google Maps application, but uses either OpenStreetMap, Microsoft VirtualEarth or CloudMade as a data source for tiles. You could add support for loading tiles from your own custom service.