diff --git a/openlayers/package-lock.json b/openlayers/package-lock.json index 758af91..7c1f6ba 100644 --- a/openlayers/package-lock.json +++ b/openlayers/package-lock.json @@ -9,7 +9,7 @@ "version": "0.2.0", "license": "BSD-3-Clause", "dependencies": { - "pmtiles": "^2.10.0" + "pmtiles": "2.11.0" }, "devDependencies": { "esbuild": "^0.15.11" @@ -591,9 +591,9 @@ } }, "node_modules/pmtiles": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/pmtiles/-/pmtiles-2.10.0.tgz", - "integrity": "sha512-X+s6JyperpcAkKwv55MKx72ckOUB0ZjcfK4929iM0SS0MkLydEi2FSW1E8YTE1E2XaZ2TVk/MIUrbsZuXV7K2g==", + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/pmtiles/-/pmtiles-2.11.0.tgz", + "integrity": "sha512-dU9SzzaqmCGpdEuTnIba6bDHT6j09ZJFIXxwGpvkiEnce3ZnBB1VKt6+EOmJGueriweaZLAMTUmKVElU2CBe0g==", "dependencies": { "fflate": "^0.8.0" } diff --git a/openlayers/package.json b/openlayers/package.json index 03d7d0a..f5bd853 100644 --- a/openlayers/package.json +++ b/openlayers/package.json @@ -26,7 +26,7 @@ "prettier-check": "prettier --check *.js" }, "dependencies": { - "pmtiles": "^2.10.0" + "pmtiles": "2.11.0" }, "devDependencies": { "esbuild": "^0.15.11" diff --git a/openlayers/src/index.js b/openlayers/src/index.js index 247edf9..d079eed 100644 --- a/openlayers/src/index.js +++ b/openlayers/src/index.js @@ -22,7 +22,11 @@ export class PMTilesRasterSource extends DataTile { }, }); - const p = new pmtiles.PMTiles(options.url); + const fetchSource = new pmtiles.FetchSource( + options.url, + new Headers(options.headers), + ); + const p = new pmtiles.PMTiles(fetchSource); p.getHeader().then((h) => { this.tileGrid.minZoom = h.minZoom; this.tileGrid.maxZoom = h.maxZoom; @@ -59,7 +63,7 @@ export class PMTilesVectorSource extends VectorTile { format.readFeatures(tile_result.data, { extent: extent, featureProjection: projection, - }) + }), ); tile.setState(TileState.LOADED); } else { @@ -84,7 +88,11 @@ export class PMTilesVectorSource extends VectorTile { }, }); - this.pmtiles_ = new pmtiles.PMTiles(options.url); + const fetchSource = new pmtiles.FetchSource( + options.url, + new Headers(options.headers), + ); + this.pmtiles_ = new pmtiles.PMTiles(fetchSource); this.pmtiles_.getHeader().then((h) => { this.tileGrid.minZoom = h.minZoom; this.tileGrid.maxZoom = h.maxZoom; diff --git a/openlayers/src/script_includes.js b/openlayers/src/script_includes.js index 633f52c..e011f43 100644 --- a/openlayers/src/script_includes.js +++ b/openlayers/src/script_includes.js @@ -1,5 +1,8 @@ // IMPORTANT: this file is manually edited! // copy any changes made from src/index.js to here +// to automate this we need a rollup or esbuild script +// to resolve the imports to the ol global correctly +// as well as get the enum values of TileState, which is elided // import DataTile from "ol/source/DataTile"; // import VectorTile from "ol/source/VectorTile"; @@ -25,7 +28,11 @@ export class PMTilesRasterSource extends ol.source.DataTile { }, }); - const p = new pmtiles.PMTiles(options.url); + const fetchSource = new pmtiles.FetchSource( + options.url, + new Headers(options.headers), + ); + const p = new pmtiles.PMTiles(fetchSource); p.getHeader().then((h) => { this.tileGrid.minZoom = h.minZoom; this.tileGrid.maxZoom = h.maxZoom; @@ -62,7 +69,7 @@ export class PMTilesVectorSource extends ol.source.VectorTile { format.readFeatures(tile_result.data, { extent: extent, featureProjection: projection, - }) + }), ); tile.setState(2); } else { @@ -87,7 +94,11 @@ export class PMTilesVectorSource extends ol.source.VectorTile { }, }); - this.pmtiles_ = new pmtiles.PMTiles(options.url); + const fetchSource = new pmtiles.FetchSource( + options.url, + new Headers(options.headers), + ); + this.pmtiles_ = new pmtiles.PMTiles(fetchSource); this.pmtiles_.getHeader().then((h) => { this.tileGrid.minZoom = h.minZoom; this.tileGrid.maxZoom = h.maxZoom;