ol-pmtiles passes headers like other ol source options (#261)

This commit is contained in:
Brandon Liu
2023-10-01 11:29:50 +08:00
committed by GitHub
parent 8c282b90da
commit 0cba01d8a6
4 changed files with 30 additions and 11 deletions

View File

@@ -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;