polyines on iphone - iphone

I want to know how to display the route between two Points on
map using mapkit framework in iphone
Is there any Api that can used to display the route between two
Pins. If not Is Polyines is standard to show route between two
pins.Can we display the route on Map with the help of polyines on iphone
or is it dummy route between two points.
Thanks in advance

There's a nice sample on how to accomplish this with a custom MKAnnotationView here: http://spitzkoff.com/craig/?p=108

You can find a working example at http://github.com/leviathan/nvpolyline This solution is especially targeted at iPhone OS versions prior to v.4.0
Although it can also be used in v.4.0 Hope this helps.

You could use Quartz to draw your lines.
Get the context of your map view
Move to the point of your first pin
Add a point to the point of your second pin
Configure your stroke (line-style, width, color)
Draw
A good tutorial about drawing with Quartz:
http://www.cocoadevcentral.com/d/intro_to_quartz_two/

If you do this you will have your app rejected. You are not allowed to use the Google Map tiles (and thus MapKit) for routing.
You can use one of the open map frameworks, they may also support API's for drawing routes atop them. I would explore that before figuring out how to draw your own polylines.

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

Display Black&White MapKit

I'm working on an app with a MapKit map, which I want to display as Black&White, rather than the default color scheme.
How do I do that?
Is there a method I can set the color scheme with?
Are there specific constants I can set for the color scheme?
Is there a combination of masking the MapKit view with some image that applies an effect of Black&White?
Thanks,
Nur
You can use route-me instead of UIMapView and select the desired mapsource that suits you.
There's no way to change the colour of the map in MKMapView. The only thing you can change really is the mapType property which defines if it's a standard map, satellite or hybrid.
I doubt you'd be able to easily do anything with an overlay to make it B&W either. It might even be a violation of the terms of using the Google maps to do that anyway - I'm not sure on that, but it's possible it is.
So if you really need it B&W then I suggest using something other than the standard MKMapView.
To expand on some of the answers:
You cannot set MapKit to black and white. It violates the terms of use.
Your best bet is you use route-me with an offline tileSource. Google TileMill. They allow you to create your own maps from shape files which you can download off different sites. You then use route-me to display the maps you created.

Tile Overlays in iPhone App

There is a webpage I am looking at that displays a Google Map (via javascript), but certain areas of the map have an overlay (textures appear different than the rest of the map, etc.). From what I can gather, this is done on the webpage via a getTileURL function, which depends on the zoom level and current coordinate.
I am interested in portraying this same overlay in my iPhone application, which currently has a mapView set up. Is there anyway to implement the same sort of getTile function in objective-c for a mapView?
If someone could please provide some sample code or point me in the right direction I would greatly appreciate it. Thank you.

Use an Image as an MKOverlayView (iPhone MKMapKit)

We want to use MapKit / MKOverlayView to create a map that looks totally customized. We would create a PNG that has the local streets / points of interest, and match that up to MapKit map.
I am finding some info that seems to infer that this is possible, but all the tutorials and examples I find are dealing with drawing lines and polygons, which is not what we want.
I have also considered the possibility of creating the PNG, grabbing the user's location and mathematically calculating their position on the image... but that seems like a bigger task than potentially using a MKOverlayView
Any ideas about how to get started would be much appreciated.
You could start by looking at Open Maps I believe you can customise their maps by creating your own XML file (different styles of roads etc..) You can then download the map tiles as PNGs or lazy load them in your app.
Google maps on the other hand you are not allowed to modify or store in you application.
However if you choose the open maps approach you have to effectively roll your own MapKit. This is tricky but very much possible. Start by looking at the apple developer videos on tiled scroll views.

Using custom map with MKMapKit

I am creating an iPhone app for OS4.0, and I am attempting to integrate a custom map with a standard MKMapView. I have been provided a map in .eps format (vector image), and I want to somehow overlay this on an MKMapView in and restrict the scrolling boundaries of the map so users cannot scroll outside the boundaries of the custom map. What's the best way to go about this?
I have read some stuff about hosting map tiles on a server, but this seems overly complex for my application. This would just be a map for an attraction roughly the size of a public zoo, so I would think that it would be conceivable to just convert the .eps to a .png file, and overlay it, but this might not give the best performance.
I understand that I could conceivable use a UIScrollView to do the job, but the problem is that I have dynamically generated MKPinAnnotationViews placed on the map, whose position must be based on latitude and longitude, so I can't think on an elegant or reasonable way to do it with a scrollview. Any ideas?
Thanks!
-Matt
Apple has a great bit of example code that will show you what you need to do. Check out the TileMap sample - it is available as part of the (free) WWDC 2010 samples download.
It shows you how to use the gdal2tiles utility to convert an input map into a tree of overlay tiles.
Another good bit of Apple sample code to check out is HazardMap, which is part of the regular SDK samples.