Driving Directions in the map - iphone

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.

Related

How to zoom at particular point in google maps added to uiwebview?

I have google maps added to UIWebview. I want to zoom the map to destination location. Destination location is passed programmatically.
How do I do it? I tried setting parameter z=10 while loading google maps url but it doesn't zoom at particular point.
Please help
Thanks
Why you dont use MapKit?
It uses google map to provide the map.
http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MapKit_Framework_Reference/_index.html
if you really want to use google maps inside an webview you will need to do something like that:
http://maps.google.com/maps?q=24.197611,120.780512&z=10
where q=latitude,longitude
and you will need to know the latitude and longitude of the point you want to zoom
for more informations you can look at:
http://mapki.com/wiki/Google_Map_Parameters
I solved it with by adding certain parameters to the google maps url:
http://maps.google.com/?saddr=%#&daddr=%1.6f,%1.6f&ll=%#&sll=%#&sspn=0.015&output=embed&z=15

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.

How to draw line between two coordinates in iphone application using titanium?

I am implementing one stock display ipad application in which i want to display graph.
But I dont know how to draw graph.I want to draw graph in view not in webview.
I have tried to find out on google.But not got success.
Can you please give us advice about this query.
Thanks in advance.
You can use the following tutorial to teach you how to draw lines on a view. Found with a simple Google search ;-) http://www.ifans.com/forums/showthread.php?t=132024

Get Place Location

I need put information about place, where is iPhone now, to UILable in my screen. [Country][City][Street] and maybe coordinates [lat][lng]. For example in my UILable should be:
Your location is German, Berlin, Tiergarten
Can someone show me really simple code how can i get such information that put in my UILable?
The MapKit framework (part of iPhone OS 3.0) provides this for you. Specifically the MKPlacemark object, which you can obtain for a set of co-ordinates using an MKReverseGeocoder.
You need access to a reverse geocoding service, which will take your lat/lon coordinates as input and return some kind of structured address of that location.
Google's is available here: http://code.google.com/apis/maps/documentation/geocoding/index.html#ReverseGeocoding

Showing Driving Directions in MapKit

is there any way to show the driving directions in iphones MapKit?
is there any way to get the coordinates and names of a route as an XML or in other formates from google MAPs API ?
eg , http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=39.23232,-103.343433&daddr=41.23232,-104.344343&ie=UTF8&z=12
No, you cannot use MapKit for driving directions. It does not support this.
However, you could improvise a transparent view on top of MapKit and draw something, but nothing native to MapKit.
EDIT: Here is a sample of drawing routes yourself:
http://spitzkoff.com/craig/?p=65
You should try Kishikawa Katsumi's project MapKit-Route-Directions is really well made and useful. You can find the sample project at github https://github.com/kishikawakatsumi/MapKit-Route-Directions.git
You can add to your view UIWebView. Than load to UIWebView something like this
http://code.google.com/apis/maps/documentation/examples/directions-simple.html