Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. function GoogleMap_selected(){
  2.  
  3. var lattitude_value= document.getElementById('slectedLat').value;
  4. var longitude_value= document.getElementById('slectedLon').value;
  5.  
  6. var from = new google.maps.LatLng(mylatitude, mylongitude);
  7. var to = new google.maps.LatLng(lattitude_value, longitude_value);
  8.  
  9. var directionsService = new google.maps.DirectionsService();
  10. var directionsRequest = {
  11. origin: from,
  12. destination: to,
  13. travelMode: google.maps.DirectionsTravelMode.DRIVING,
  14. unitSystem: google.maps.UnitSystem.METRIC
  15. };
  16.  
  17. this.initialize = function(){
  18. var map = showMap_selected();
  19.  
  20. directionsService.route(
  21. directionsRequest,
  22. function(response, status)
  23. {
  24. if (status == google.maps.DirectionsStatus.OK)
  25. {
  26. new google.maps.DirectionsRenderer({
  27. map: map,
  28. directions: response
  29. });
  30. }
  31. else
  32. {
  33. alert("Unable to retrive route");
  34. }
  35.  
  36. }
  37. );
  38.  
  39. }
  40.  
  41. var showMap_selected = function(){
  42. var mapOptions = {
  43. zoom: 12,
  44. center: new google.maps.LatLng(lattitude_value, longitude_value),
  45. mapTypeId: google.maps.MapTypeId.ROADMAP
  46. };
  47. var map = new google.maps.Map(document.getElementById("selected_map_canvas"), mapOptions);
  48. return map;
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement