   'async!http://maps.googleapis.com/maps/api/js?sensor=true' + if window.location.host is 'localhost' then '' else '&key=AIzaSyDZj9_A4WUDGph6cKf2A7VsFbDz6Pb7QBk'
 ], ($, _, Backbone, MapRouteView) ->
       
+
+  # Roughly the greater Helsinki area
+  maxBounds = new google.maps.LatLngBounds(
+    new google.maps.LatLng 59.99907, 24.152104
+    new google.maps.LatLng 60.446654, 25.535784
+  )
+
   class MapView extends Backbone.View
 
     el: $('#map')
 
     initialize: ->
-      # If we already have the user's current position, use it. If not, center
-      # the map to it as soon as everything is initialized and we have the
-      # location.
-      if window.initialPosition
-        @currentPosition = new google.maps.LatLng(window.initialPosition.coords.latitude,
-          window.initialPosition.coords.longitude)
-      else
-        Reitti.Event.on 'position:change', (position) =>
-          _.once @centerMap(position)
-
       Reitti.Event.on 'position:change', (position) =>
         @displayCurrentPosition position
 


    render: ->
      @map = new google.maps.Map(@el,
        center: @currentPosition or new google.maps.LatLng(60.171, 24.941) # Rautatieasema
        zoom: 16
        mapTypeId: google.maps.MapTypeId.ROADMAP
        mapTypeControlOptions:
          position: google.maps.ControlPosition.TOP_CENTER
        minZoom: 10,
        maxZoom: 18
      )
      @

    drawRoute: (route) =>

    panToLegBounds: (leg) =>
      @map.fitBounds @routeView.getBoundsForLeg(leg)
      
    centerMap: (lat, lng) ->
      latLng = new google.maps.LatLng lat, lng
      @map.setCenter(latLng) if maxBounds.contains(latLng)

    displayCurrentPosition: (position) ->
      latLng   = new google.maps.LatLng position.coords.latitude, position.coords.longitude
