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

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.

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

Xcode: How do I make a map that can show nearby locations?

I'm in the process of making an iPhone App that can show nearby stores (the stores are a danish grocerychain of stores). In the app. I want to switch to a view where the standard iphone map is shown and I know how to make that and a pointer of my location.
Now i have a list of all the addresses of the stores. But i don't know how to make the map automatically show for example 4 or 5 of the nearest stores of my current location.
Also I would really like that when the map launches it doesn't show the entire world but it automatically zooms in on my current location in a decent way :)
I hope someone will help. I would really appreciate it :)
What you want is not as simple as flipping a switch, but it can certainly be done:
Fetch the list of nearby store locations based on the current location of the device. Use Core Location to get the current device location and then fetch the nearby stores from either a file within the app bundle or from somewhere on the web
Display the stores on a map provided by MapKit using annotations. To make sure only a relevant part of the map is show use the setRegion:animated: method of MKMapView

Is it possible to show a path between two annotations using the MapKit API?

I am working on an app that will show the user the closest locations from a database to the user. When the user selects one of these locations from a list, the user will then see a map on a new screen showing an annotation representing the user, and another annotation representing the location.
Is it possible using the MapKit API to show the user a path from the user to the location? I am not asking about how to show turn by turn directions. I just want to display a path between the two annotations. Is this possible?
In iOS 4.x, Apple added support for map overlays. It might help to read a little bit more about the MKPolyline & MKPolylineView classes and the mapView:viewForOverlay: method defined in the MKMapViewDelegate protocol. All available in the Map Kit Framework Reference.

MKMapView Road Map

How to Get Route from user current Location to Destination location in MkMapView?
You need to handle that yourself. Get the gps data somewhere for the route and draw the lines yourself.
I don't think that's something allowed in Mapkit. I believe it's part of the restrictions to prevent Mapkit from being used for a turn by turn application.
You can use MapKit for showing maps, but when it comes to routing you'll have to launch out to the Maps app. In the URL launching Maps you can pass the destination's lat/long coordinates and have it place pin. The user can then find their way there from their current location.

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