unicef / magicbox-maps

Map mobility data in a NodeJS + React front-end application with data served by magicbox-open-api
http://magicbox-maps.azurewebsites.net
BSD 3-Clause "New" or "Revised" License
11 stars 11 forks source link

Color layers by aggregation #74

Closed mikefab closed 6 years ago

mikefab commented 6 years ago

8 lines of code by @carloscdias

    let matches = document.querySelectorAll("input[name=region]:checked");
    let atts_to_aggregate = Array.prototype.slice.call(matches).reduce((a,t) => {
      a.push(['get', t.value])
      return a
    }, ['+'])
    this.state.map.setPaintProperty(
      'regions',
      'fill-opacity',
      ['/', atts_to_aggregate, atts_to_aggregate.length-1]
    )

screen shot 2018-03-28 at 5 41 01 pm screen shot 2018-03-28 at 5 41 14 pm screen shot 2018-03-28 at 5 41 20 pm