From 674e92624dfa3cd4aded79535b0b20d9ae9d077a Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Fri, 28 Oct 2022 10:56:18 +0800 Subject: [PATCH] improve OpenLayers example; maxzoom and TileState --- js/examples/openlayers.html | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js/examples/openlayers.html b/js/examples/openlayers.html index c53f80d..75d72f6 100644 --- a/js/examples/openlayers.html +++ b/js/examples/openlayers.html @@ -35,14 +35,18 @@ const y = +result[4]; tile.setLoader((extent, resolution, projection) => { - this._p.getZxy(z,x,y).then((result) => { - if (result) { + tile.setState(1); // LOADING + this._p.getZxy(z,x,y).then((tile_result) => { + if (tile_result) { const format = tile.getFormat(); - const features = format.readFeatures(result.data.buffer, { + const features = format.readFeatures(tile_result.data.buffer, { extent: extent, featureProjection: projection }); tile.setFeatures(features); + tile.setState(2); // LOADED + } else { + tile.setState(4); // EMPTY } }); }); @@ -65,7 +69,7 @@ declutter: true, source: new ol.source.VectorTile({ attributions:["© Land Information New Zealand"], - maxZoom: 15, // this could come from the PMTiles header (async) + maxZoom: 14, // this could come from the PMTiles header (async) format: new ol.format.MVT(), // this could come from the PMTiles header (async) url:source.url(), tileLoadFunction: source.tileLoadFunction