maps.chandlerswift.com/layers/nhl-arenas/layer.js

31 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-07-03 17:13:20 -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, Circle, Fill} from 'ol/style.js';
import url from './data.geojson?url'; // TODO: remove `?url`?
2023-07-03 17:13:20 -05:00
import visitedArenas from './visited.js'
const vectorLayer = new VectorLayer({
source: new VectorSource({
url: url,
2023-07-03 17:13:20 -05:00
format: new GeoJSON,
}),
// TODO: use '✓' and '✗' (or maybe '✔' and '✘') (from https://en.wikipedia.org/wiki/List_of_Unicode_characters#Dingbats)
// TODO: popups with Arena information (name, photo, date visited, score from that day)
style: function(feature, resolution) {
const base_color = visitedArenas.some(a => a.name == feature.get('name')) ? '#008800' : '#FF0000';
return new Style({
image: new Circle({
radius: 50/Math.pow(resolution, 1/4),
fill: new Fill({color: base_color + '33'}),
stroke: new Stroke({color: base_color, width: 1}),
}),
});
}
});
export default vectorLayer;