     visible_layers[0].setOpacity 1 - state.layer_b_opacity
     visible_layers[1].setOpacity state.layer_b_opacity
     current_state.visible_layers = visible_layers
+    if current_state.year != year
+        current_state.year = year
+        year_changed = true
+    else
+        year_changed = false
 
     update_years state
 

    $("#year_b").html orto_years[state.layer_a_idx + 1]
    $("#year_a").css {opacity: 1 - state.layer_b_opacity}
    $("#year_b").css {opacity: state.layer_b_opacity}

    # Set visibility flags on all layers and hide the non-visible layers.
    for al in orto_layers

        if not l.added
            l.addTo map
            l.added = true

    if year_changed
        redraw_buildings()


# When the map starts moving, remove all non-visible layers
# to save on bandwidth cost.
