![](/img/trans.png)
[英]Openlayers 4+ using local vector tiles (.pbf) without server
[英]Openlayers Pbf vector tiles bad performance
因此,我在平移/放大和缩小直到渲染图块之前使用 pbf 矢量图块时遇到了性能问题(例如,如果您尝试在图块渲染之前放大和平移,屏幕将很快冻结),渲染完成后一切运行顺利. 需要注意的是,我正在为 android/IOS 实现离线地图功能,并且我在我的设备上存储了 pbf 图块。 所以这就是我目前正在做的事情:
// create vector tile layer
const layer = new VectorTileLayer({
source: new VectorTileSource({
format: new MVT(),
url: 'offline-pbfs/{z}/{x}/{y}.pbf', // Url on device
tileLoadFunction: this.tileload,
maxZoom: 14
})
});
// custom load tiles function for loading tiles from device storage
private tileload = (tile, url) => {
tile.setLoader((extent, resolution, projection) => {
this.file.readAsArrayBuffer(this.file.dataDirectory, url)
.then(data => {
const format: any = tile.getFormat();
tile.setFeatures(format.readFeatures(data, {extent}));
})
.catch(err => logger.error(err, 'Error loading tile', url));
});
}
// obtain and apply osm-bright-style.json
this.offlineMapService.getOfflineMapStyle().subscribe(styleData => {
applyStyle(layer, styleData, 'openmaptiles').then((_: any) => {
this.map.addLayer(layer);
});
})
我尝试过使用 renderOrder、renderBuffer、renderMode、declutter 选项,但没有帮助。 另外我在这里你可以看到在缩放/平移地图时口吃,它只是不平滑。 任何帮助将不胜感激
每次缩放、平移等都会重新设计功能,如果每次都重新定义样式,它会很慢。 如果您可以将样式保存为每个特征一次的变量,则在后续缩放时从变量中获取样式,而不是再次创建样式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.