我正在尝试渲染矢量瓦片在开放图层地图4.3.3版本中的栅格瓦片之上。两个瓦片都得到渲染,但矢量瓦片没有显示在光栅tiles.For上例如,我有一个州的矢量瓦片,并希望这显示为半透明层上的栅格瓦片。我已经将我的矢量瓦片存储在S3存储桶中,而tileLoadFunction从S3存储桶中获取这些矢量瓦片。我还没有设置任何投影。我认为tileLoadFunction有一些默认的投影。
下面是我用来显示这两个磁贴的代码:
var map = new ol.Map({
layers: [
new ol.layer.Tile({
name: 'Tile',
type: 'GeoJSON',
source: new ol.source.XYZ({
url: 'https://api.tiles.mapbox.com/v4/mapbox.emerald/{z}/{x}/{y}.png?access_token=' + MAPBOX_KEY
})
}),
new ol.layer.VectorTile({
name: 'VectorTile',
type: 'MVT',
source: new ol.source.VectorTile({
format: new ol.format.MVT(),
renderMode: 'vector',
tileGrid: ol.tilegrid.createXYZ({ maxZoom: 14 }),
url: 'data',
tileLoadFunction: tileLoadFunction
}),
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(0, 0, 0, 0.5)'
}),
stroke: new ol.style.Stroke({
color: 'white',
width: 3
})
})
})
],
target: 'map',
view: new ol.View({
center: [-7400327.330457623, 2062576.7712471967],
maxZoom: 20,
minzoom: 2,
zoom: 8
})
});
function tileLoadFunction(tile, url) {
getSignedUrl(url, function(s3Url) {
var loader = ol.featureloader.loadFeaturesXhr(s3Url, tile.getFormat(),
tile.onLoad.bind(tile),
tile.onError.bind(tile));
tile.setLoader(loader);
}谁能指导一下,这里缺少什么才能正确地将矢量瓦片显示为栅格瓦片上的半透明层?
谢谢,
发布于 2017-10-03 14:26:17
下面是我做的一个样例项目,可以根据你的需要自定义矢量和栅格层。我认为这会帮助你解决你的问题。
https://stackoverflow.com/questions/46455477
复制相似问题