How to draw route in map in iphone - iphone

I want to draw route in map, for this I am storing latitude and longitude in my server. when this view opens it fetches all lat and long from server and plots it in mapView. Suppose server gets new lat and long this should show in mapView without closing this view, means map has plotted route if it gets new lat and long this route should continue from last point.

Apple supplied a demo application called Breadcrumb with the 2010 WWDC Developer videos that does exactly this. You can get the sample code from here: http://developer.apple.com/videos/wwdc/2010/

We wrote a category to mapKit that allow you to show route over the map :
http://code.google.com/p/octomapkit/
Very easy to use :
[youMap addRouteFrom:startCoord to:endCoord zommed:shouldZoom]
Hope this helps,
Vincent

Related

Showing a given location on a map in XCode (iPhone)

I am developing an app that will take in two locations from the user, one of which can be the standard 'current location', the second will be a location of the user's choosing. First of all, I simply want to plot these two locations on a map view.
Can anyone help me take a place name (e.g. Boston MA) from the user via a textfield and get the decimal coordinates as well as dropping a pin on the map?
Read the Location Awareness guide, especially chapter
UsingGeocoders
This will deliver a coordinate for given free text.
Further search in the Apple Developper Center for Demo code for that Geocoder.
Further there is a LocateMe demo code from Apple, which uses the map (MkMapKit)

how to draw route from userlocation to some pin in iphone sdk?

I am implementing map based application in iPhone sdk. I want to give functionality in map view like Google maps directoins. means is at some location from that he selects one pin from multiple pins from MKPinAnnotationView. is it possible that user can get direction from his current location to selected pin location in MapView? user can select any aanonations from that he can get directions in some way of line to his current location to pin location. i have get some idea from here
but this all was some static data you can download this example.
here also apple example. but this example is only for track & draw line for user movement.
is it possible that user can get direction from his current location to selected pin location in MapView?
Yes. You can send a query to google maps api using your current location and the selected annotation location. When google responds with the route, you will use that polyline decoder method to decode the data and draw the route on your map view.
I have got all side idea from here
this can be useful for other developers also.
i have found some other examples also that can be also useful for other developers just google. you will find this is polyline link for user current location use this apple code
Here is Google direction api. Read it and use it.
For test purpose you can check this request
http://maps.googleapis.com/maps/api/directions/json?origin=28.459497,77.026638&destination=28.435600,77.009997&sensor=true
And use JSON Viewer to see the json response.

Driving Directions in the map

I have a view based application and in that I want to show driving directions on map.
I searched for it on google, I got the google maps driving directions api but I didn't got how to use it in program directly webview or is there any other way to use that api programmatically. Any help appreciated.
If you want my advice (and this is the way I do things), use an UIWebView and use a Javascript-based sample to to ask Google to draw directions for you.
It's easy!
Use this link:
http://maps.google.com/maps?f=q&saddr=25.612524,85.128281&daddr=28.574815,77.236545&output=kml
or
http://maps.google.com/maps?f=q&saddr=patna&daddr=new+delhi&output=kml
You can use both web services, one with lat and long ,where second one is with saddr(source address) and daddr(destination address). It gives you xml file parse it and make array of intermediately lat-long points . I think u know how to draw route on MKMapView with the help of Overlay class.
**If you need to finding lat long of given name of location ,use this link:
http://maps.google.co.in/maps?t=h&z=10&hl=en&format=p&q=new+delhi&output=kml
**Keep in mind that ,if location name have two or more then two words then it combines with + operator.
You should take a look at MKMapViewController for displaying maps. Take a look at this tutorial on how to draw routes with MKPolyline.

getting lat long from mapView iphone?

all , iam developing an ipad app that uses mapview to display google maps, my problem was how to get lat long of a perticular region, some how i manged to get by putting an overlay on the map view and getting point of that view , then converted to lat long. now my problem is i want to show an movable pointpin on the view so that user easily point the required region.
If any idea please send me .
Thanks
Kumar Y R
Use DDAnnotation in map view
here is the link to download
it has a sample where you can drag the pin and drop it where you need.

how to get Region using Specified string in GoogleMaps in Iphone?

In my iphone application i am using MKMapView to display any region(i.e Australia) and it is working fine using coordinates(latitude and longitude).But i want to display the region based on the string (i.e Australia) instead of the coordinates.
Lets say i click on the TableView with named string as "Australia" and in the next view it should display Australia with some pinpoints on that.
how to display any region based on the String instead of the given coordinates?
provide any solution with any code snippet or any useful link or any other ,which would be appreciated.
Thanks,
Mishal Shah
You need Geocoding. Querying the server for "Australia" should return the coordinates you need.