open layers example: set raster tile size to 512x512 [#3]

This commit is contained in:
Brandon Liu
2023-04-26 16:33:34 +02:00
parent d15e9a5760
commit fb0ea53ea2

View File

@@ -28,7 +28,8 @@
constructor(options) { constructor(options) {
super({ super({
state: "loading", state: "loading",
attributions: options.attributions attributions: options.attributions,
tileSize: options.tileSize
}); });
const p = new pmtiles.PMTiles(options.url); const p = new pmtiles.PMTiles(options.url);
@@ -41,7 +42,6 @@
const blob = new Blob([response.data]); const blob = new Blob([response.data]);
const src = URL.createObjectURL(blob); const src = URL.createObjectURL(blob);
const image = await this.loadImage(src); const image = await this.loadImage(src);
image.width = 512;
URL.revokeObjectURL(src); URL.revokeObjectURL(src);
return image; return image;
}); });
@@ -50,11 +50,11 @@
} }
} }
// TODO: tile size 512,512
const rasterLayer = new ol.layer.WebGLTile({ const rasterLayer = new ol.layer.WebGLTile({
source: new RasterPMTilesSource({ source: new RasterPMTilesSource({
url:"https://r2-public.protomaps.com/protomaps-sample-datasets/terrarium_z9.pmtiles", url:"https://r2-public.protomaps.com/protomaps-sample-datasets/terrarium_z9.pmtiles",
attributions:["https://github.com/tilezen/joerd/blob/master/docs/attribution.md"] attributions:["https://github.com/tilezen/joerd/blob/master/docs/attribution.md"],
tileSize: [512,512]
}) })
}); });
@@ -64,7 +64,7 @@
target: 'map', target: 'map',
view: new ol.View({ view: new ol.View({
center: [0,0], center: [0,0],
zoom: 0, zoom: 1,
multiWorld: true multiWorld: true
}), }),
}); });