{% block geojson_reader %}

  <script>
    // Assumes `extents` has already been parsed

    // Add collected polygons to map
    let reader = geo.createFileReader('geojsonReader', {
      'layer': layer
    });

    reader.read(extents.collect, (features) => {
      var fill = '#6586c9';
      if (extents.count > 1) {
        var scale = d3.scale.category10();
        fill = function (d, i, p, j) {
          return scale(j);
        }
      }
      features[0].style({
        fillColor: fill,
        fillOpacity: 0.75,
      })
      .draw();
    });

  </script>
{% endblock %}
