我正在尝试从 GeoServer 添加图层;它工作正常,但删除图层不起作用。这是我的代码:
function loadTOCLayer(layerName) {
var tl = new ol.layer.Tile({
extent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34],
source: new ol.source.TileWMS( /** @type {olx.source.TileWMSOptions} */ ({
url: 'http://172.16.1.58:8080/geoserver/KBJNL/gwc/service/wms',
params: {
'LAYERS': layerName,
'TILED': true
},
serverType: 'geoserver'
}))
});
map.addLayer(tl);
}
function removeTOCLayer(ss) {
map.removeLayer(ss);
}
Run Code Online (Sandbox Code Playgroud)