使用开放层添加第二层,第二层添加来自OSM的第二层,而第二层来自地理服务器localhost。但是,当我加载单个OSM层时,默认情况下会显示其地图。
可以,但是
添加第二层时不起作用。它的老地图也消失了
var MapLayer = new ol.layer.Tile({
source: new ol.source.OSM()
});
var myView = new ol.View({
center: [74.1296577, 32.2739606],
zoom: 4,
projection: projection
});
var mymap = new ol.source.TileWMS({
url: 'http://localhost:8080/geoserver/DHAGIS/wms',
params: { 'LAYERS': 'DHAGIS:baddoki', 'TILED': true, 'STYLES': 'graves' },
serverType: 'geoserver',
});
var mylayer = new ol.layer.Tile({
source=mymap
});
//////////////////////////
var map = new ol.Map({
target: 'map',
layers: [MapLayer, mylayer
],
view: myView
});