与olms一起使用时,OpenLayers t.getScaleArray不是函数



我想在OpenLayers中包含一个矢量平铺贴图,并使用GL样式文件来设置贴图的样式。因此,我使用的是olmapbox样式(olms(。我包括ol6.4.3版和olms 6.1.3版。我想在id为"的DOM对象中呈现我的映射;地图";。我从OpenMapTiles服务器获取我的tiles,我自己托管(在localhost:32768上(。这是我的代码:

const vectorTileLayer = new ol.layer.VectorTile({
source: new ol.source.VectorTile({
attributions: [
'<a href="http://www.openmaptiles.org/" target="_blank">&copy; OpenMapTiles</a>',
'<a href="http://www.openstreetmap.org/about/" target="_blank">&copy; OpenStreetMap contributors</a>',
],
format: new ol.format.MVT(),
url: 'http://localhost:32768/data/v3/{z}/{x}/{y}.pbf',
maxZoom: 18,
}),
});
this.map = new ol.Map({
target: 'map',
loadTilesWhileAnimating: true,
loadTilesWhileInteracting: true,
view: new ol.View(this.viewConfig),
});
fetch('http://localhost:32768/styles/osm-bright/style.json').then(function(response) {
response.json().then(function(glStyle) {
olms.applyStyle(vectorTileLayer, glStyle, 'openmaptiles').then(function() {
me.map.addLayer(vectorTileLayer);
});
});
});

我尝试了来自不同来源的不同实现(使用stylefunction((函数,使用apply((函数(,并消除了可能导致错误的所有其他因素。

如果我用地图加载页面,我会得到一个愚蠢的错误:

TextBuilder.js:502 Uncaught TypeError: t.getScaleArray is not a function
at e.setTextStyle (TextBuilder.js:502)
at Point (vector.js:239)
at vector.js:123
at Fo (vector.js:102)
at e.renderFeature (VectorTileLayer.js:565)
at e.x (VectorTileLayer.js:258)
at d (VectorTileLayer.js:271)
at e.updateExecutorGroup_ (VectorTileLayer.js:286)
at e.prepareTile (VectorTileLayer.js:131)
at e.dispatchEvent (Target.js:114)

当我没有从Tile服务器获取样式(并使用olms应用它们(,并且在创建地图后立即添加图层时,我不会出错,但当然我也没有样式。

我还包括了这个样式文件中需要的字体。

对于所有遇到相同问题的人,请查看Mike对该问题的评论。

您将需要使用OpenLayers版本6.3.1,因为olms似乎基于版本6.1.0https://github.com/openlayers/ol-mapbox-style/blob/master/package.json#L36因此它不支持6.4.0版本中引入的二维图标和文本比例

这似乎在很大程度上解决了问题。

最新更新