1if($('#map_canvas').length) { 2 $.when(add_js('//maps.google.com/maps/api/js?key=AIzaSyBhu5ibJC_Df3aYWZW_ryElSDtrQbvg9HA&sensor=false')).done(function() { 3 var directionsDisplay; 4 var directionsService = new google.maps.DirectionsService(); 5 var map; 6 var marker; 7 var oldDirections = []; 8 var currentDirections = null; 9 10 function initialize() { 11 var myOptions = { 12 zoom: 14, 13 center: new google.maps.LatLng($('#map_canvas').attr('data-latitude'),$('#map_canvas').attr('data-longitude')), 14 mapTypeId: google.maps.MapTypeId.ROADMAP 15 } 16 map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 17 18 marker = new google.maps.Marker({ 19 position: new google.maps.LatLng($('#map_canvas').attr('data-latitude'),$('#map_canvas').attr('data-longitude')), 20 map: map 21 }); 22 23 directionsDisplay = new google.maps.DirectionsRenderer({ 24 "map": map, 25 "preserveViewport": false, 26 "draggable": true 27 }); 28 29 30 directionsDisplay.setPanel(document.getElementById("directions_panel")); 31 32 google.maps.event.addListener(directionsDisplay, "directions_changed", 33 function() { 34 if (currentDirections) { 35 oldDirections.push(currentDirections); 36 } 37 currentDirections = directionsDisplay.getDirections(); 38 }); 39 } 40 41 function calcRoute(start,end) { 42 if(!start) { 43 showAlert("You must enter a start address.","bad"); 44 return false; 45 } 46 47 if(!end) { 48 showAlert("You must enter an end address.","bad"); 49 return false; 50 } 51 52 marker.setMap(null); 53 54 var request = { 55 origin:start, 56 destination:end, 57 travelMode: google.maps.DirectionsTravelMode.DRIVING 58 }; 59 60 directionsService.route(request, function(response, status) { 61 if (status == google.maps.DirectionsStatus.OK) { 62 directionsDisplay.setDirections(response); 63 } 64 }); 65 } 66 67 initialize(); 68 69 $("#go").click(function() { 70 var start = document.getElementById("start").value; 71 var end = document.getElementById("end").value; 72 73 calcRoute(start,end); 74 return false; 75 }); 76 77 $("#start").keydown(function(e) { 78 if(e.keyCode==13) { 79 $("#go").click(); 80 } 81 }); 82 }); 83}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.