tags:

views:

1151

answers:

3

Hello,

I want to draw a route between 2 locations on the map.. something as a tour guide.When the tourist clicks another location i want to be able to draw the route as well as inform the distance from current location.

I am aware of sites on the internet which tell how to draw polylines on map. But,one such example had a preloaded .csv file with various coordinates.

Is there an alternate way to get the coordinates..as the location is selected dynamically.If no, how do i get the information for intermediate coordinates?

Am a newbie. so please dont mind me asking this question.

Thanks in advance.

+4  A: 

Tricky one. There is no way to do that with mapkit : its easy enough to draw lines when you know the coordinates, but mapkit won't give you access to the roads or other routing information. I'd say you need to call an external API to get your data.

I've been playing with cloudmade.com API. The vector stream server should return what you need, and then you can draw that over your map. However, discrepancies between the google maps and the OSM maps used by cloudmade may make you want to use cloudmade maps all the way: they have an equivalent to mapkit.

p.s. Other mapping providers - Google, Bing etc may also provide equivalent data feeds, I've just been looking at OSM/Cloudmade recently.

p.p.s. None of this is trivial newbie stuff! Best of luck!

Andiih
+4  A: 

Andiih's got it right. MapKit won't let you do that. Unfortunately, Google won't let you do what you want to do either.

When Apple announced MapKit and all, they also explicitly stated that any navigational applications would be BYOM: Bring Your Own Maps, so any navigation application uses their own set of mapping tools.

Google's Terms of Service restrict you from even displaying routes on top of their maps:

http://code.google.com/intl/de/apis/maps/iphone/terms.html

License Restrictions:

10.9 use the Service or Content with any products, systems, or applications for or in connection with:

(a) real time navigation or route guidance, including but not limited to turn-by-turn route guidance that is synchronized to the position of a user's sensor-enabled device;

(b) any systems or functions for automatic or autonomous control of vehicle behavior; or

(c) dispatch, fleet management, business asset tracking, or similar enterprise applications (the Google Maps API can be used to track assets (such as cars, buses or other vehicles) as long as the tracking application is made available to the public without charge. For example, you may offer a free, public Maps API Implementation that displays real-time public transit or other transportation status information.

Sadly, this includes what you would like to do. Hopefully one day MapKit will be expanded to allow such features... although unlikely.

Good luck.

Jus' Wondrin'
PRN doesn't say he's trying to do anything enterprise or turn-by-turn : just that he wants to overlay directions. This is something you can do with the Google Maps Javascript API (I think), but not MapKit. You are obviously more familiar with the Google API than me - if its not turn-by-turn is there any way of getting road vectors out ? [see this question has got me interested now!]
Andiih
A: 

You might want to have a look at http://github.com/mobilemelting/nvpolyline This solution is especially targeted at iPhone OS versions prior to v.4.0

Although it can also be used in v.4.0 Hope this helps.

Colins
Hi Colins,First of all sorry for the delayed reply...but with the example mentioned above, the co-ordinates are hardcoded within the application,what i want is to get the co-ordinates as and when the location is selected...not something where the co-ordinates are preloaded. For instance,a tourist could pick any random location in a city, and should be provided the route based on his/her current co-ordinates. This selected location's co-ordinate may not be preloaded.
PRN
PRN please head over to the polyline GitHub project and open an issue report (http://github.com/mobilemelting/nvpolyline/issues). I will try to incorporate a solution for your problem in the project.
Colins