aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.js90
1 files changed, 46 insertions, 44 deletions
diff --git a/main.js b/main.js
index c1c7da9..a125a97 100644
--- a/main.js
+++ b/main.js
@@ -4409,54 +4409,56 @@ const [mapLayers, featureOverlayLayer] = (function() {
if (!canWebGL2) {
rasterLayers.forEach((k) => ret[k] = null);
} else {
- rasterLayers.forEach((k) => ret[k] = new TileLayerGL({
- /* Naturvårdsverket has a WMS server we could use instead, but by serving it ourselves
- * we can filter on he various kskog classes */
- source: new GeoTIFF({
- sources: [{
- url: baseurl + 'raster/' + k + '.tiff',
- }],
- normalize: false,
- convertToRGB: false,
+ rasterLayers.forEach(function(k) {
+ ret[k] = new TileLayerGL({
+ /* Naturvårdsverket has a WMS server we could use instead, but by serving it ourselves
+ * we can filter on he various kskog classes */
+ source: new GeoTIFF({
+ sources: [{
+ url: baseurl + 'raster/' + k + '.tiff',
+ }],
+ normalize: false,
+ convertToRGB: false,
+ wrapX: false,
+ interpolate: false,
+ /* use the projection found in the source's metadata */
+ }),
+ visible: false,
+ style: null, /* filled later */
+ });
+ map.addLayer(ret[k]);
+ });
+ }
+
+ vectorLayers.forEach(function(k) {
+ ret[k] = new VectorTileLayer({
+ source: new VectorTile({
+ url: baseurl + 'tiles/' + k + xyz,
+ format: new MVT(),
projection: projection,
wrapX: false,
- interpolate: false,
+ transition: 0,
+ tileGrid: tileGrid,
}),
- visible: false,
- style: null, /* filled later */
- }));
- rasterLayers.forEach((k) => map.addLayer(ret[k]));
- }
-
- vectorLayers.forEach((k) => ret[k] = new VectorTileLayer({
- source: new VectorTile({
- url: baseurl + 'tiles/' + k + xyz,
- format: new MVT(),
- projection: projection,
- wrapX: false,
- transition: 0,
- tileGrid: tileGrid,
- }),
- /* XXX switch to 'hybrid' if there are perf issues; but that seems to
- * put lines above points regardless of their respective z-index */
- renderMode: 'hybrid',
- declutter: false,
- visible: isVisible(k),
- style: function(feature, resolution) {
- const style = styles[k + '.' + feature.getProperties().layer];
- if (!Array.isArray(style)) {
- return style;
- } else {
- const maxi = style.length - 1;
- const z = 10 /* Math.log2(maxResolution) */ - Math.log2(resolution);
- /* use Math.floor() as VectorTile.js calls getZForResolution(resolution, 1) */
- const i = z <= 0 ? 0 : z >= maxi ? maxi : Math.floor(z);
- // console.log(`resolution=${resolution}, z=${z}, i=${i}`);
- return style[i];
+ /* XXX switch to 'hybrid' if there are perf issues; but that seems to
+ * put lines above points regardless of their respective z-index */
+ renderMode: 'hybrid',
+ declutter: false,
+ visible: isVisible(k),
+ style: function(feature, resolution) {
+ const style = styles[k + '.' + feature.getProperties().layer];
+ if (!Array.isArray(style)) {
+ return style;
+ } else {
+ const maxi = style.length - 1;
+ const z = 10 /* Math.log2(maxResolution) */ - Math.log2(resolution);
+ /* use Math.floor() as VectorTile.js calls getZForResolution(resolution, 1) */
+ const i = z <= 0 ? 0 : z >= maxi ? maxi : Math.floor(z);
+ // console.log(`resolution=${resolution}, z=${z}, i=${i}`);
+ return style[i];
+ }
}
- }
- }));
- vectorLayers.forEach(function(k) {
+ });
ret[k].set('layerGroup', k, true);
map.addLayer(ret[k]);
});