var directionDisplay;
var directionsService = new google.maps.DirectionsService();
var map;

function initialize() {
  directionsDisplay = new google.maps.DirectionsRenderer();
  var bavinckschool = new google.maps.LatLng(52.406948,4.648052);
  var myOptions = {
    zoom:9,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    center: bavinckschool
  }
  map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
  directionsDisplay.setMap(map);
  directionsDisplay.setPanel(document.getElementById("directionsPanel"));
}
  
function calcRoute() {
  var straat = document.getElementById("straat").value;
  var stad = document.getElementById("stad").value;
  var adres = straat+","+stad+", Nederland";
  var request = {
    origin:adres, 
    destination:"Ambachtstraat 1, Haarlem",
    travelMode: google.maps.DirectionsTravelMode.DRIVING
  };
  directionsService.route(request, function(response, status) {
    if (status == google.maps.DirectionsStatus.OK) {
      directionsDisplay.setDirections(response);
    }
  });
}

