How to show directions to neares places from current location using MKMapView - iphone

I am new to using MapKit on iPhone.
On Google Maps, I have a current location and push pins to indicate nearest places around current location. (The co-ordinates of all are hard-coded as on now).
Now, How to do the following:
1. Display a green arrow (right/left arrow) pointing to the nearest push pin location from current location?
2. How to play a voice saying "Take right for 1 mile" etc to reach nearest location from current location?

I don't have a definite solution but some ideas which might help you.
You can probably use a custom MKAnnotationView whose image will be the green arrow. You can then place this annotation (arrow) on top of your current location. Then you can find the closest pin (by checking its distance to the current location) and find the angle between the pin and the current location. With that angle you can rotate your arrow image so that it points towards the nearest pin.
You can get the user's current location and heading and you can get the distance from the current location to the nearest pin. With this information you can figure out how far and in what direction the user needs to travel. I'm not sure if you want to synthesize the voice or if you have audio files ready. You'll probably have to play back short clips back to back (eg "take" + "right" + "for" + "1" + "mile"). Have a look at Apple's audio programming guide. As far as I know, you can't get street-specific directions in the current mapkit (eg. turn right on Main street).
Good luck.

Related

Is It Possible To "Transpose" The User's Location?

What I would like to do is specify a location (for instance, a street corner in Paris) and have an MKMapView treat that as the user's current position. As the user moves away from his/her true position the deltas are reflected as changes to that "transposed" location. In other words: can I fool an MKMapView into "believing" that I am standing wherever I choose in the world and have it track my movements as though I were actually there?
Edit:
Actually, the real question is: Can I fool Core Location and thereby fool an MKMapView? The application wherein I would be displaying the transposed MKMapView would be interacting with Core Location.

how to get current location as i slide the MapView?

I am using CLLocationManager to retrieve current location in my app and display using MapView, i want to slide the map so that the current location should also change to the new location where the map slides and it should annotate to the new location, how to do it? Please give your suggestions with sample code.
You probably don't mean "the current" since that means where the phone actually is, unless you want to transport the phone to another place when using this app which would be quite a feat. So, how about drawing a layer over the top of your map that keeps a pin drawn at the centre so it looks as if the pin is moving over the map, but really the map is moving under the pin.

Iphone maps direction question

In the iPhone maps application under directions, if I try to search for directions with current location and the destination being a place ex:Shell gas station, sometimes it returns the result of the Shell station closest to my location. At other times this returns the address in some other state in the US. This happens randomly.
Any clues why this happens or any way to get around it ?
Searching for a point of interest (POI) in the Maps application tries to use the region defined by the visible map area to search. If that is too large an area, it uses your last known location. If you'd like it to search for shell gas stations near you, touch the 'current location' button and then do the search.

draw route on static image map iphone

I'm developing a campus navigation app.
I have an image which displays building on the campus.
I want draw a route from the user location to destination building the use wants to go.
Wondering how to draw a route on static custom image.
Been searching on internet but cannot find any clue how to develop.
All documentation on internet are about drawing route on Google map.
any hint will be much much appreciated.
You'll have to manually collect latitude and longitude information for each of your map image's four corners. You'll also have to manually specify, in terms of co-ordinates on the image, the position of every possible turning point in the building's corridors, stairs etc. Then you can get the device's current latitude and longitude (see the Location Awareness Programming Guide), translate it into a position on your image, and overlay a transparent view with a red line on it stopping at each of your manually collected waypoints. There remains the graph theory problem of finding the shortest route through the network of waypoints. I suggest the A* algorithm.

Putting GPS current location and pin annotations on a UIImageView

I am making an iPhone app for a local college. I am currently trying to take a drawn map of the campus and put pin annotations on it. I also want to be able to show the users current location on this map image. Right now I just have a UIImageView inside of a UIScrollView. It can currently scroll and zoom in/out. How would I go about accomplishing this? I have searched everywhere for an answer and can't seem to find a solution (or have overlooked it). Am I going in the right direction? Thanks for your help.
You would have to come up with a function to translate latitude and longitude into pixel offsets in the image. Assuming the campus is relatively small compared to the Earth (so you can ignore the planet's curvature), this should be a simple matter of determining the coordinates of the four corners of the image and interpolating.