Possible to Draw Custom Routes on MKMapKit ? (iOS) - ios

I know that it is possible to add annotations to an iOS Map.
Is it possible to draw a custom path (such as a path cutting through a park) on my MKMapView and then create a route on the MKMapView using that custom path?

Add MKCircle overlay
In viewForOverlay: create a bezierPath (CG or UI) and add it to the path property of a standard MKOverlayPathView instance
go through this to understand in detail
http://spitzkoff.com/craig/?p=65
hope it helps. happy coding :)

Related

Create Custom Maps Xcode?

I would like to Create a Custom Map !
There is a way to do it so as to add this map to Xcode ?
I have an example in this picture below:
http://a1.mzstatic.com/eu/r30/Purple2/v4/92/d6/a8/92d6a818-1966-3a87-da0e-1aa6251d7e6a/screen568x568.jpeg
Thanks
Many way to do it.
Easy one is add UIImageView to UIScrollView and enable zoom on scrollview.
this way you can have basic map not good in memory.
Or, you can use some opensource like Mapbox, you can custom tile image map.
https://www.mapbox.com/

MapKit overlays to add floor plans to map

I am trying to add an overlay to iOS MapKit in order to show floor plans. However, I am unsure about the best way of doing this. If I add the floor plans by using an MKOverlay, will the floor plans be loaded lazily or do I need to find out which part of the map is being displayed and update overlays thereafter? I also looked at using MKTileOverlay, as it is using lazy loading, but I have the impression that it should be used for completely covering of the map and not only to add to the existing one. Is this correct?
Yes, you are right MKTileOverlay can cover whole map with tiles and Yes it is using lazy loading.
Use MKOverlay if you are not willing to replace native look and fill of map. You can also achieve lazy loading for MKOverlay too.
Note: MKTileOverlay will not remove your already existing MKAnnotations and MKOverlay.
MKOverlay is a protocol, not a class. You want MKTileOverlay as of iOS 7. Things are lazy loaded according to what portion of the map is currently shown.
You might find this useful as a reference on how the tiles are numbered and organized:
https://www.mapbox.com/foundations/how-web-maps-work/
As for covering Apple's map, this will happen by default, but you can also adjust the MKOverlayLevel used to place it between Apple's base map and labels layer, or you can use canReplaceMapContent = YES if you want to disable Apple's maps entirely.

how to create a variable radius in map view

I have a map view and I want to add a variable radius like in the find friends app, allowing the user to drag to make the radius smaller or bigger. How do I do this? Is there any prebuilt functionality that allows you to do this easily?
MKCircle is the class you are looking for. It conforms to the MKAnnotation protocol, so you can just use it like any other annotation. Use the MKCircleView class for the actual drawing of the circle (also check the available sample code).
It can be possible by just using a custom MKAnnotationView that shows a circle? That will maintain size as you zoom around.

How to add Annotation pin for source and destination in iOS using two color?

I am developing a small project, which will display the source and distance trace route, I did complete till that, now the thing is I am unable to add two annotation pin of different color for source and destination, suppose I am using red for source and green for destination.
This might be huge help for everybody who are learning and working.
Thanks
You could use images for your pins or you could use a subclass of MKAnnotationView - MKPinAnnotationView and just change the pinColor property, it's documentation can be found here:
http://developer.apple.com/library/ios/#DOCUMENTATION/MapKit/Reference/MKPinAnnotationView_Class/Reference/Reference.html#//apple_ref/occ/cl/MKPinAnnotationView

Use custom map image in UIMapView

I wanna accomplish the following, i wanna display a static map image that i have on UIMapView to use the benefits of the zooming and annotation, i've search very hard and i came up with these solution.
There is a library called route-me that give you the ability to customize the map, change the color of the map, specify a predefined road and building, highlight them, but it didn't help me in my issue.
I've looked on apple example that using the MKOverLay class, HazardMap, KMLViewer but they are not showing how to use an image to replace it with the map.
All i want is to display a map image that i have for a place and use it in UIMapView. can anyone put me in the right direction.
Thx in advance.
I replied to this question in this other post. Maybe it helps you:
How do I create an image overlay and add to MKMapView?

Resources