 update_years = (state) ->
     year_a_idx = state.layer_a_idx
     opacity = 1 - state.layer_b_opacity
-    console.log year_a_idx
-    console.log opacity
     for year_el, idx in $("#year_list div")
         if idx == year_a_idx
             opa = opacity * (1 - MIN_OPACITY)


    return {layer_a_idx: layer_a_idx, layer_b_opacity: layer_b_op, year: year}

update_screen = (val) ->
    if val == current_state.val
        return

        opacity: 1.0
        fillOpacity: 0.4
    year = parseInt feat.properties.valmvuosi
    if current_state.year and year > current_state.year
        ret.opacity = 0
        ret.fillOpacity = 0
    if not year or year == 9999
        color = '#eee'
    else
        start_year = 1890
        end_year = new Date().getFullYear()
        if year < start_year
            year = start_year
        n = Math.floor (year - start_year) * colors.length / (end_year - start_year)
        n = colors.length - n - 1
        color = colors[n]
    ret.color = color
    return ret

building_layer = null

window.show_buildings = false

map.on 'moveend', ->
    if map.getZoom() < 16 or not window.show_buildings
        if building_layer
            map.removeLayer building_layer
            building_layer = null
        return
    str = map.getBounds().toBBoxString() + ',EPSG:4326'
    get_wfs 'hel:rakennukset',
        maxFeatures: 500
        bbox: str
        propertyName: 'valmvuosi,osoite,wkb_geometry_s2'
        , (data) ->
            if building_layer
                map.removeLayer building_layer
            building_layer = L.geoJson data,
                style: building_styler
                onEachFeature: (feat, layer) ->
                    year = feat.properties.valmvuosi
                    address = feat.properties.osoite
                    layer.bindPopup "<b>Valm.vuosi #{year}</b><br/>#{address}"
            building_layer.addTo map
