通过idesktop制作的两个图层,如下所示:
这个两个图层发布到iserver上能够单独显示,但是通过iserver进行图层覆盖之后,只能显示单一图层
代码如下:
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>twoMap</title>
<style type="text/css">
/* body{ */
/* margin: 0; */
/* overflow: hidden; */
/* background: #fff; */
/* } */
/* #map{ */
/* position: relative; */
/* height: 520px; */
/* border:1px solid #3473b7; */
/* } */
/* #toolbar { */
/* position: relative; */
/* height: 33px; */
/* padding-top: 5px; */
/* } */
</style>
<!-- <link href='./css/bootstrap.min.css' rel='stylesheet' /> -->
<!-- <link href='./css/bootstrap-responsive.min.css' rel='stylesheet' /> -->
<script src='../libs/SuperMap.Include.js'></script>
<script type="text/javascript">
var map, layerWorld, layerJingjing;
// var url="http://localhost:8090/iserver/services/map-wmts-vec/rest/maps/vec";
// var url2="http://localhost:8090/iserver/services/map-wmts-cva/rest/maps/cva";
// var url3="http://localhost:8090/iserver/services/map-jingjin/rest/maps/京津地区人口分布图_专题图";
var url="http://localhost:8090/iserver/services/map-ChinaProvinces2/rest/maps/ChinaProvinces";
// var url="http://localhost:8090/iserver/services/map-china400/rest/maps/China";
var url2="http://localhost:8090/iserver/services/map-ChinaProvinces2/rest/maps/BuildRegion@China2";
function init(){
map = new SuperMap.Map("map",{controls: [
// new SuperMap.Control.LayerSwitcher(),
new SuperMap.Control.MousePosition(),
new SuperMap.Control.ScaleLine(),
// new SuperMap.Control.OverviewMap(),//鹰眼
new SuperMap.Control.Zoom(),
new SuperMap.Control.Navigation({
dragPanOptions: {
enableKinetic: true
}
})
], allOverlays: true
});
layerWorld = new SuperMap.Layer.TiledDynamicRESTLayer("ChinaProvinces", url, {transparent: true, cacheEnabled: true});
layerWorld.events.on({"layerInitialized": addLayer1});
}
function setLayerOpacity(){
var numStr = document.getElementById('layerOpacity').value;
if(numStr && !isNaN(numStr)){
if(Number(numStr) >= 0 && Number(numStr) <= 1){
layerJingjing.setOpacity(Number(numStr));
}
}
}
function addLayer1(){
layerJingjing = new SuperMap.Layer.TiledDynamicRESTLayer("BuildRegion@China2", url2, {transparent: true, cacheEnabled: true});
layerJingjing.events.on({"layerInitialized": addLayer2});
layerJingjing.setOpacity(0.6);
}
function addLayer2(){
map.addLayers([layerWorld,layerJingjing]);
map.setCenter(new SuperMap.LonLat(104.21,35.34), 1);
}
</script>
</head>
<body onload="init()">
<div id="map" style="width:100%;heigth:100%"></div>
</body>
</html>