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)
Related
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.
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
I just want to display the lat/lon on the screen of an iPhone.
I've read a half dozen examples, and everyone decides to do 3 other cool things at the same time and soon I am in over my head.
I would love a link to an example of plain vanilla (not kitchen sink like Apple's LocateMe) example of where I need to set up the CLLocation object, how do I turn it on, put lat/lon in a variable, and then turn it off.
Here is a link with how to build an app that does nothing but display your lat/long: Lat/Long Display App
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
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