Find Address for mapView - iphone

I currently have a mapView being displayed in an iPhone app. I'm wondering if there is a way to put an address field, allow the user to enter an address, and then have the map re-center over the coordinates of that particular address?
Would appreciate any help, thank you.

Yes, it's definitely possible. However, you will need to use a 3rd party api for the google forward geocoding (address --> lat/long).
http://blog.sallarp.com/ipad-iphone-forward-geocoding-api-google/
Forward geocode the address string and use annotation to place it on the map.

There certainly is a way to do that. The way to do this would be to have a UITextField in which the user enters the address and a button, which when pressed sends over a web request to google map api which returns the actual longitude/latitude pertaining to the address and then the mapview can be re centered to those coordinates dropping a pin at that point.
EDIT:
Explained above is the way I implemented it. Instead of a UiTextField and a button you can also use a UISearchBar and here's a nice link that can get you going.
How to search MKMapView with UISearchBar?

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.

Using a Street Address in iOS

Is there anyway to take in a Street Address ("1234 Test Ave. New York, NY) and be able to create an annotation for a map? Basically my app current marks the users location and I want to make the location of an event (A button pushes the mapView on screen). I want to obtain the coordinates of that event so that I can place an annotation on the mapView that is being displayed on screen.
Any ideas?
To translate GPS coordinates into addresses you can use MKReverseGeocoder, to translate addresses into GPS coordinates you need to use a 3rd party geocoding tool or write a wrapper for some service yourself. I wrote one for one of my apps and open sourced it. Check it out on GitHub

Selecting a location with MapKit

Is there a best practice or common pattern for allowing users to select a precise location on a map using MapKit?
I've seen examples where a user can enter an address in a search box. But what about the case where a user doesn't know the exact address and wants to select a location from the map?
It's a bit more complex task than it seems.
Here is the guide how to detect single taps on a Web View.
I've used the same pattern to detect single taps on Map View but allowing zooming and dragging at the same time.
Hope it helps.
I would say that replicating the Maps application is close to a best practice for map applications.
You can test it for yourself; tap and hold somewhere on the map and a pin that you can move around by dragging will be dropped where you held your finger.
The Google Maps app seems to tackle what is a reasonable idea by touching the map by instead allowing you to drop a pin on the map; the SO post might help out.