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
Related
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)
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
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.
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?
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.