                 real_time_view.$('.real-time').addClass(data.delta_class()).show()
       @$('.segments').append(view.render().el)
       @$('.progress').hide()
+
+
+  fit_bounds: =>
+    point = (latlng) -> new L.LatLng(latlng[0], latlng[1])
+    points = (leg) ->_.map decodeLine(leg.legGeometry.points), point
+    legs = _.map @model.get('itineraries').first().get('legs'), points
+    bounds = new L.LatLngBounds(_.reduce legs, (a, b) -> a.concat(b))
+    @map.fitBounds(bounds)

    latlngs = (new L.LatLng(point[0], point[1]) for point in points)
    polyline = new L.Polyline(latlngs, color: color, opacity: 0.6, clickable: false)
    @plan_route.addLayer(polyline)
    # zoom the map to the polyline
    #@map.fitBounds(new L.LatLngBounds(latlngs))


  add_segments: (plan) =>

    Transit.events.on 'plan:complete', @add_segments
    @model.on 'geocode fetch', @fetch_plan
    @model.on 'change:from change:to', @update_markers
    Transit.events.on 'plan:complete', @fit_bounds
    @plan_route = new L.LayerGroup()

  render: =>
