| 110 | }; |
| 111 | |
| 112 | constructor( |
| 113 | options: VectorTileSourceOptions<RenderFeature> & { url: string | Source }, |
| 114 | ) { |
| 115 | super({ |
| 116 | ...options, |
| 117 | ...{ |
| 118 | state: "loading", |
| 119 | url: "pmtiles://{z}/{x}/{y}", |
| 120 | format: options.format || new MVT(), |
| 121 | }, |
| 122 | }); |
| 123 | |
| 124 | this.pmtiles_ = new PMTiles(options.url); |
| 125 | this.pmtiles_.getHeader().then((h: Header) => { |
| 126 | const projection = options.projection || "EPSG:3857"; |
| 127 | const extent = options.extent || extentFromProjection(projection); |
| 128 | this.tileGrid = |
| 129 | options.tileGrid || |
| 130 | createXYZ({ |
| 131 | extent: extent, |
| 132 | maxResolution: options.maxResolution, |
| 133 | maxZoom: options.maxZoom !== undefined ? options.maxZoom : h.maxZoom, |
| 134 | minZoom: h.minZoom, |
| 135 | tileSize: options.tileSize || 512, |
| 136 | }); |
| 137 | this.setTileLoadFunction(this.tileLoadFunction); |
| 138 | this.setState("ready"); |
| 139 | }); |
| 140 | } |
| 141 | } |