iServer 8c ,js开发,底图为切片,想在底图上加载wms图层。
问题描述:
单独加载底图或wms图层均可显示,但先加载底图后,无法在其上加载wms图层。浏览器不报错。
实现代码:
加载底图:
function init(){
//初始化地图
map = new SuperMap.Map("map",{controls:[
new SuperMap.Control.Navigation() ,
new SuperMap.Control.ScaleLine(),
new SuperMap.Control.Zoom()
]});
map.addControl(new SuperMap.Control.MousePosition());
//初始化图层
layer = new SuperMap.Layer.TiledDynamicRESTLayer("地图", url,{transparent: true, cacheEnabled:true},{maxResolution:"auto"});
//监听图层信息加载完成事件
//layer.events.on({"layerInitialized":addBaseLayer});
mapDiv=document.getElementById("map");
}
//异步加载图层
function addBaseLayer(){
map.addLayer(layer);
//显示地图范围
map.setCenter(new SuperMap.LonLat(121.63469, 38.91935),8);
}
加载wms:
function addLayerWms(){
var wms=new SuperMap.Layer.WMS("WMS1", url1, { layers: "路段面@大连全数据", version: '1.3.0'}, {projection:"EPSG:4326",maxExtent: new SuperMap.Bounds(121.28,38.79 ,121.73,39.09)});
map.addLayers([wms]);
map.setCenter(new SuperMap.LonLat(121.63469, 38.91935),8);
//mapDiv.focus();
}
单独加载可显示(图片):