2023-07-25 17:42:31 -05:00
|
|
|
import VectorLayer from 'ol/layer/Vector';
|
|
|
|
import {Vector as VectorSource} from 'ol/source.js';
|
|
|
|
import GeoJSON from 'ol/format/GeoJSON.js';
|
|
|
|
|
|
|
|
import {Style, Stroke} from 'ol/style.js';
|
|
|
|
|
2023-07-25 19:12:30 -05:00
|
|
|
import url from './data.geojson?url'; // TODO: remove `?url`?
|
2023-07-25 17:42:31 -05:00
|
|
|
|
|
|
|
const colors = '0,0,0'; // from their website's cookie banner, and other places
|
|
|
|
|
|
|
|
const vectorLayer = new VectorLayer({
|
|
|
|
source: new VectorSource({
|
|
|
|
url: url,
|
|
|
|
format: new GeoJSON,
|
|
|
|
}),
|
|
|
|
style: function(feature, resolution){
|
|
|
|
return new Style({
|
|
|
|
stroke: new Stroke({
|
|
|
|
color: `rgba(${colors},${Math.min(1, Math.pow(resolution/10, 1/4))})`,
|
|
|
|
width: 10/Math.pow(resolution, 1/4),
|
|
|
|
})
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default vectorLayer;
|