Skip to content

Commit

Permalink
Merge pull request #13 from am2222/bugfix/mp-11-fix-crash-on-invalid-…
Browse files Browse the repository at this point in the history
…zoom

Bugfix/mp 11 fix crash on invalid zoom
  • Loading branch information
am2222 authored Jun 5, 2024
2 parents c7ed818 + 04684c1 commit 407ae99
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,13 @@ export class PmTilesSource extends VectorTileSourceImpl {
this.fire(new Event("dataloading", { dataType: "source" }));
// We need to get both header and metadata
this._tileJSONRequest = Promise.all([this._instance.getHeader(), this._instance.getMetadata()]).then(([header, tileJSON]: any) => {
//first we set some of the header properties to the source using tileJSON
extend(this, tileJSON);
// fix for the corrupted tilejson
this.minzoom = Number.parseInt(this.minzoom.toString()) || 0;
this.maxzoom = Number.parseInt(this.maxzoom.toString()) || 0;

// we set min and max zoom from the header
this.header = header;
const { specVersion, clustered, tileType, minZoom, maxZoom, minLon, minLat, maxLon, maxLat, centerZoom, centerLon, centerLat } = header

Expand All @@ -316,10 +322,8 @@ export class PmTilesSource extends VectorTileSourceImpl {
this._tileJSONRequest = undefined;
this._loaded = true;

extend(this, tileJSON);
// fix for the corrupted tilejson
this.minzoom = Number.parseInt(this.minzoom.toString()) || 0;
this.maxzoom = Number.parseInt(this.maxzoom.toString()) || 0;


// we set this.type after extend to avoid overwriting
this.tileType = tileType

Expand Down

0 comments on commit 407ae99

Please sign in to comment.