Skip to content

Commit

Permalink
below zoom 9 display static choropleth of districts from TopoJSON [#121]
Browse files Browse the repository at this point in the history
  • Loading branch information
bdon committed Apr 9, 2022
1 parent ae7c022 commit a341cce
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/lib/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Vector as VectorSource, OSM, Cluster } from 'ol/source'
import { Zoom, ScaleLine, Rotate, Attribution } from 'ol/control'
import Geolocation from 'ol/Geolocation'
import { defaults as defaultInteractions, PinchRotate } from 'ol/interaction'
import TopoJSON from 'ol/format/TopoJSON'

import { FactoryData, defaultFactoryDisplayStatuses, FactoryDisplayStatusType, FactoryDisplayStatuses } from '../types'
import { flipArgriculturalLand } from '../lib/image'
Expand Down Expand Up @@ -532,6 +533,28 @@ export class OLMap {
view.setZoom(zoom)
}

private getChoroplethLayer () {
return new VectorLayer({
maxZoom:9,
source: new VectorSource({
url: 'datasets/districts-10t.json',
format: new TopoJSON({
layers: ['districts'], // or counties
}),
overlaps: false,
}),
style: new Style({
fill: new Fill({
color: '#A1A1A1',
}),
stroke: new Stroke({
color: 'white',
width: 1,
})
})
});
}

private instantiateOLMap (target: HTMLElement, baseLayer: TileLayer | VectorTileLayer, options: OLMapOptions = {}) {
const tileGrid = getWMTSTileGrid()

Expand All @@ -558,7 +581,8 @@ export class OLMap {
target,
layers: [
baseLayer,
getLUIMapLayer(tileGrid)
getLUIMapLayer(tileGrid),
this.getChoroplethLayer()
],
view,
controls: [
Expand Down

0 comments on commit a341cce

Please sign in to comment.