Advertisement
Guest User

Untitled

a guest
Oct 4th, 2012
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var map;
  2. var Loc1;
  3.  
  4. $('#mapPage').live('pageshow',
  5.         function(event, ui) {
  6.             var mapOptions = {
  7.                 zoom : 7,
  8.                 mapTypeId : google.maps.MapTypeId.ROADMAP,
  9.                 center : Loc1
  10.             };
  11.  
  12.             map = new google.maps.Map(document.getElementById('map_canvas'),
  13.                     mapOptions);
  14.         });
  15.  
  16. function initialize(Hlat1, Hlng1, Hlat2, Hlng2) {
  17.     Loc1 = new google.maps.LatLng(Hlat1, Hlng1);
  18.  
  19.     var $content = $("#mapPage div:jqmData(role=content)");
  20.     $content.height(screen.height);
  21.     $.mobile.changePage($("#mapPage"));
  22.  
  23.     calcRoute(Hlat1, Hlng1, Hlat2, Hlng2);
  24. }
  25.  
  26. function calcRoute(Hlat1, Hlng1, Hlat2, Hlng2) {
  27.     var rendererOptions = {
  28.         draggable : true
  29.     };
  30.     var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
  31.     var directionsService = new google.maps.DirectionsService();
  32.  
  33.     var request = {
  34.         origin : new google.maps.LatLng(Hlat1, Hlng1),
  35.         destination : new google.maps.LatLng(Hlat2, Hlng2),
  36.         travelMode : google.maps.DirectionsTravelMode.DRIVING
  37.     };
  38.    
  39.     directionsService.route(request, function(response, status) {
  40.         if (status == google.maps.DirectionsStatus.OK) {
  41.             directionsDisplay.setDirections(response);
  42.             directionsDisplay.setMap(map);
  43.         }
  44.     });
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement