Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing directions on Google Maps

I think this would be very basic question. I am building an application using codigniter in which the users have to mark the destination on the map and Google Maps should automatically draw a route from a point to destination point and save it. We would then have to use the saved route to reach the user.

I am new to Maps API. Any resources where I can study how to implement this using Google Maps API or other Maps APIs? I would also like to know whether this kind of implementation in Google Maps API would affect the privacy of user?

like image 748
naquiuddin Avatar asked Oct 08 '11 22:10

naquiuddin


1 Answers

If you're asking users to click the map to mark a start destination, I'm not sure how this affects their privacy?

Anyway, what you want to do is have an event listener attached to the map, for a click event. When the user clicks, find out the latlng of that point, and draw directions between that point and your other point. Here's an example of an event listener which gets the coordinates of a user's click on the map: http://code.google.com/apis/maps/documentation/javascript/events.html#EventArguments

I guess you could then save the DirectionsResult with an Ajax call to a php page.

like image 104
duncan Avatar answered Sep 22 '22 18:09

duncan