Get Place Location - iphone

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

Related

Is GPS Spoofing possible in iOS sdk?

Is there any way in iOS to spoof the GPS location. I mean to say show user different coordinates not the real one ?
Thanks!
As far as i know gps gives you lat long and you show it on map.
What you can do is add your code in between to spoof obviously iam not talking about the default app. Look at heversine formula it will be helpfull
take care of water bodies and buildings you dont want to spoof the position of car in ocean iguess
the most easiest way to do that is make the map annotation you own,
you may look that this https://github.com/samvermette/SVPulsingAnnotationView
hide the original one & make a fake annotation view with any location you want

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.

iPhone Direction Arrow?

I need to create an iPhone simple view that, based on the location of the user in the world, points the person to a never-changing Long/Lat location.
Is it possible to know this from the iPhone API?
Any examples?
This is possible on the current (3GS) iPhone, but not on earlier versions (which did not have a compass). The APIs that you'll need to use are in the CoreLocation.framework.
Search the app store for "mecca" and you'll turn up many, many applications that do exactly what you're asking about. You'll also find several applications that let you drop a pin anywhere on the map and have the app point you to it.
I've recently written code that does almost exactly what you describe.
Here's what you ned to do:
Calculate a heading from your current location to your target location. You should use "great circle" calculations, so they show a correct heading even when the destination is over the horizon. I found code (in Javascript) at this link to show me how to do this:
http://www.movable-type.co.uk/scripts/latlong.html
You want the section titled "bearing"
That code uses javascript library routines like "math.sin(x)" You can pretty much just delete the "math." part, and the trig functions work as is.
That will give you your bearing in radians.
You then need to get your compass heading (if on a 3Gs phone), convert it to radians, and use the compass heading to correct for the orientation of the phone. If you're running on a 3G, you can skip the compass heading and show the bearing based on North being at the top of the phone, and let the user orient their phone towards North themselves.
Duncan C

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.