function init_map() {
  var location = {lat: 47.20388, lng: 8.58176};
  var center;
  if ($(window).width() > 840) {
    center = {lat: location.lat, lng: location.lng + 0.06};
  } else {
    center = {lat: location.lat - 0.06, lng: location.lng};
  }

  var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 12,
    center: center,
    disableDefaultUI: true,
    scrollwheel: false,
    zoomControl: true,
    zoomControlOptions: {
      position: google.maps.ControlPosition.RIGHT_TOP
    },
    styles: [
      {
        "featureType": "administrative.neighborhood",
        "stylers": [
          {
            "visibility": "off"
          }
        ]
      },
      {
        "featureType": "poi",
        "elementType": "labels.text",
        "stylers": [
          {
            "visibility": "off"
          }
        ]
      },
      {
        "featureType": "road",
        "elementType": "labels",
        "stylers": [
          {
            "visibility": "off"
          }
        ]
      },
      {
        "featureType": "water",
        "elementType": "labels.text",
        "stylers": [
          {
            "visibility": "off"
          }
        ]
      }
    ]
  });

  var image = {
    url: '/static/img/marker.png',
    size: new google.maps.Size(50, 60),
    origin: new google.maps.Point(0, 0),
    anchor: new google.maps.Point(25, 60),
    scaledSize: new google.maps.Size(50, 60)
  };
  var marker = new google.maps.Marker({
    position: location,
    map: map,
    icon: image
  });

  var input = document.getElementById('journey_calculator__input');
  if (input) {
    var result = input.parentNode.querySelector('.journey_calculator__result');
    var autocomplete = new google.maps.places.Autocomplete(input, {
        types: ['geocode'],
        componentRestrictions: {country: 'ch'}
      }
    );

    var callback_timeout;
    autocomplete.addListener('place_changed', function() {
      input.parentNode.classList.remove('error');
      input.parentNode.classList.add('loaded');
      result.classList.add('loading');
      var place = autocomplete.getPlace();

      if (!place.geometry) {
        input.blur();
        input.parentNode.classList.add('error');
      }

      var origin = new google.maps.LatLng(place.geometry.location.lat(), place.geometry.location.lng());
      var destination = new google.maps.LatLng(location);

      var service = new google.maps.DistanceMatrixService();
      service.getDistanceMatrix(
        {
          origins: [origin],
          destinations: [destination],
          travelMode: 'DRIVING'
        }, callback);

      function callback(response, status) {
        window.clearTimeout(callback_timeout);
        callback_timeout = window.setTimeout(function() {
          var duration = response.rows[0].elements[0].duration.value;
          var minutes = Math.round(duration / 60);
          result.setAttribute('data-duration', minutes);
          result.classList.remove('loading');
        }, 300);
      }
    });
  }
}