var geocoder; var directionDisplay; var directionsService = new google.maps.DirectionsService(); var map; function initialize() { directionsDisplay = new google.maps.DirectionsRenderer(); geocoder = new google.maps.Geocoder(); var startplace = new google.maps.LatLng(52.52340510, 13.41139990); var myOptions = { zoom:8,disableDefaultUI: true, mapTypeId: google.maps.MapTypeId.ROADMAP, navigationControl: true, navigationControlOptions: {style: google.maps.NavigationControlStyle.}, mapTypeControl: true, mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.}, center: startplace } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); directionsDisplay.setMap(map); directionsDisplay.setPanel(document.getElementById("map_directions")); google.maps.NavigationControlStyle.SMALL; codeAddress(''); } function codeAddress(address) { if (geocoder) { geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var infowindow = new google.maps.InfoWindow({ content: "" }); var marker = new google.maps.Marker({ position: results[0].geometry.location, title:"" }); marker.setMap(map); google.maps.event.addListener(marker, 'click', function() { infowindow.open(map,marker); }); } else { alert("Could not find the start location. Please be more specific!"); } }); } } function calcRoute() { var start = document.getElementById("fromAddress").value; var end = ''; var request = { origin:start, destination:end, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(result, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(result); } }); }