如何在Openlayers VectorTile - ol.layer.VectorTile的标头中添加身份验证令牌



我正在寻找帮助,将身份验证令牌添加为标头参数,例如持有者 - 访问令牌 - 到下面的代码。以下链接 https://github.com/openlayers/openlayers/issues/4213 包含图像磁贴的示例。

new ol.layer.VectorTile({
source: new ol.source.VectorTile({
format: new ol.format.MVT(),
url: "tile_url",
}),
style: function(feature, res) {
return new ol.style.Style({
stroke: new ol.style.Stroke({
width: 1,
color: 'rgba(0, 102, 204)'
})
})
}
})

您应该创建一个函数来提供给tileLoadFunctionol.source.VectorTile选项 在此函数中,您需要自己发出 ajax 请求并添加所需的身份验证令牌。

虽然这里是针对矢量瓦片的,但它与我之前对 WMS 案例的答案之一的原则非常相似。

最新更新