From 3892b1db69b0b6abe80cf865c6567fa867921606 Mon Sep 17 00:00:00 2001 From: Majid Date: Sat, 2 Mar 2024 03:03:23 -0500 Subject: [PATCH] dev init --- src/index.ts | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/index.ts b/src/index.ts index 160f25b..b98fefe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ import mapboxgl, { Style } from "mapbox-gl"; import { PMTiles, Protocol } from "pmtiles"; // @ts-expect-error -const VectorTileSourceImpl = Style.getSourceType("vector"); +const VectorTileSourceImpl = mapboxgl.Style.getSourceType("vector"); export const SOURCE_TYPE = "pmtile-source"; const extend = (dest: any, ...sources: any): any => { @@ -330,20 +330,8 @@ export const PmTilesSource = class PmTileSourceImpl extends VectorTileSourceImpl tile.actor = this._tileWorkers[url] = this._tileWorkers[url] || this.dispatcher.getActor(); tile.request = this._protocol.tile({ ...tile, url }, afterLoad); - // if workers are not ready to receive messages yet, use the idle time to preemptively - // load tiles on the main thread and pass the result instead of requesting a worker to do so - // if (!this.dispatcher.ready) { - - // tile.request= this._protocol.tile({ ...tile, url }, afterLoad); - // } else { - // tile.request = tile.actor.send( - // "loadTile", - // params, - // done.bind(this), - // undefined, - // true - // ); - // } + // always load tiles on the main thread and pass the result instead of requesting a worker to do so + } else if (tile.state === "loading") { // schedule tile reloading after it has been loaded tile.reloadCallback = callback; @@ -355,6 +343,6 @@ export const PmTilesSource = class PmTileSourceImpl extends VectorTileSourceImpl } } // @ts-expect-error -Style.setSourceType(PmTilesSource.SOURCE_TYPE, PmTilesSource); +mapboxgl.Style.setSourceType(PmTilesSource.SOURCE_TYPE, PmTilesSource); export default PmTilesSource;