I have been attempting to add bicycle directions to my existing google API map http://mobiiimaps.com/v1/map.htm
My goal is the following functionality: user searches for places, clicks marker to open infowindow, clicks bike icon to get directions from current location to that marker. Using the HTML5 geolocation API I have the current location in a variable that I can place in the origin option. How do I pass the markers coordinates to the destination option for the request? How do set up the click event so that the bike icon, contained in div id="bike_directions", triggers the bicycle direction function. What I have tried so far: I have followed the documentation ( https://developers.google.com/maps/documentation/javascript/directions ) and examples ( https://google-developers.appspot.com/maps/documentation/javascript/examples/directions-simple), but my javascript code is getting so long that I am having difficulty figuring out where to place the code so that it actually functions. Just to get the directions working with simple strings queries, I have tried placing the following function outside the initialize function: $(function() { $("#bike_directions").click(function calcRoute() { var request = { origin: "Los Angeles, CA", destination: "San Francisco, CA", travelMode: google.maps.TravelMode.BICYCLING }; directionsService.route(request, function(result, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(result); } }); }); }); I declared the following as global variables: var directionsDisplay; var directionsService = new google.maps.DirectionsService(); and set the following just below the initialize function directionsDisplay = new google.maps.DirectionsRenderer(); directionsDisplay.setMap(map); This did not work. Any guidance would be appreciated. I tried asking at Stackoverflow but my question was lost in the sea of questions and i did not receive an answer. Thanks -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/NzEh-iZCgPgJ. To post to this group, send email to google-maps-js-api-v3@googlegroups.com. To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.