0
我正在寫一個js腳本到多個WMS圖層添加到使用OpenLayers3
地圖的代碼是這樣的多個WMS層最好的方法:OpenLayers3:顯示在trasparency
<script type="text/javascript">
var l1 = new ol.layer.Tile({
source: new ol.source.MapQuest({layer: 'sat'})
});
var l2 = new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://pubblicazioni.provincia.fi.it/geoserver/wms',
params: {'LAYERS': 'aree_protette1'},
})
})
var l3 = new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://pubblicazioni.provincia.fi.it/geoserver/wms',
params: {'LAYERS': 'aree_protette2'},
})
})
var map = new ol.Map({
target: 'map-dashboard',
view: new ol.View({
center: [-10997148, 4569099],
zoom: 4
})
});
map.addLayer(l1);
map.addLayer(l2);
map.addLayer(l3);
</script>
這樣, WMS圖層不是全部可見的。第一個被最後一個隱藏。
閱讀API文檔,我發現ol.layer.TileWMS對象,一個可能的解決辦法是更換ImageWMS對象:
var l2 = new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://pubblicazioni.provincia.fi.it/geoserver/wms',
params: {'LAYERS': 'aree_protette1'},
})
})
var l3 = new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://pubblicazioni.provincia.fi.it/geoserver/wms',
params: {'LAYERS': 'aree_protette2'},
})
})
我需要看到的所有可見圖層和重疊。我不確定這是否是一個可行的解決方案。歡迎任何進一步的建議!