1jQuery(document).ready(function($) { 2 3 // Size the map canvas. 4 var canvas = $("#map_canvas"); 5 var parent = canvas.parent(); 6 var width = parent.innerWidth(); 7 width = width - (parseInt(parent.css("padding-left")) + parseInt(parent.css("padding-right"))); 8 var height = Math.ceil(width/16*10); 9 canvas.css({"width": width + "px", "height": height + "px"}); 10 var location = new google.maps.LatLng(mapLatitude, mapLongitude); 11 var mapOptions = { 12 center: location, 13 zoom: 16, 14 mapTypeId: google.maps.MapTypeId.ROADMAP 15 }; 16 var map = new google.maps.Map(canvas[0], mapOptions); 17 var geocoder = new google.maps.Geocoder(); 18 var directions = new google.maps.DirectionsService(); 19 var directionsDisplay = new google.maps.DirectionsRenderer(); 20 21 directionsDisplay.setMap(map); 22 23 var marker = new google.maps.Marker({ 24 position: location, 25 map: map, 26 title: propertyName 27 }); 28 29 var inputtext = $("input[name=address]"); 30 31 // Get Current Location stuff 32 if (navigator.geolocation) { 33 $("#getlocation").prop("disabled", false); 34 $("#getlocation").on('click', function() { 35 inputtext.val("Finding your location..."); 36 navigator.geolocation.getCurrentPosition(function (position) { 37 inputtext.val("Found..."); 38 var location = new google.maps.LatLng( 39 position.coords.latitude, 40 position.coords.longitude 41 ); 42 var marker = new google.maps.Marker({ 43 position: location, 44 map: map, 45 title: "Your Location" 46 }); 47 $("#directions").prop("disabled", false); 48 inputtext.attr("longitude", position.coords.longitude); 49 inputtext.attr("latitude", position.coords.latitude); 50 geocoder.geocode({latLng: location}, function(results, status) { 51 if (status == google.maps.GeocoderStatus.OK) { 52 for(index in results) { 53 var result = results[index]; 54 if (result.types.indexOf("street_address") > -1) { 55 inputtext.val(result.formatted_address); 56 return; 57 } 58 } 59 } else { 60 inputtext.val("Could not get the address for your location."); 61 } 62 }); 63 }, function () { 64 inputtext.val("Could not find your location."); 65 }); 66 }); 67 } 68 69 // Directions 70 $("#directions").on('click', function() { 71 var longitude = inputtext.attr("longitude"); 72 var latitude = inputtext.attr("latitude"); 73 var request = { 74 travelMode: google.maps.TravelMode.DRIVING, 75 destination: new google.maps.LatLng(mapLatitude, mapLongitude) 76 } 77 if (longitude != undefined && latitude != undefined) { 78 request.origin = new google.maps.LatLng(latitude, longitude); 79 } else { 80 request.origin = inputtext.val(); 81 } 82 directions.route(request, function(result, status) { 83 if (status == google.maps.DirectionsStatus.OK) { 84 directionsDisplay.setDirections(result); 85 } else { 86 alert("Could not find directions"); 87 } 88 }); 89 }) 90 91 inputtext.on('change', function() { 92 $(self).prop("disabled", false); 93 }) 94 95});
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.