iclient for classic 加载wms130错乱问题

0 投票

如图,同一幅wms130地图,用leaflet加载是正常显示,用classic加载就错乱了,是参数设置不对吗  

9月 8 分类:  63次浏览 | 用户: 人二小 (2 分)

1个回答

0 投票
您好,请问您那边具体的错误是什么,我这边测试了一下是都能正常显示预览的。
9月 8 用户: 张定祥 锋芒毕露 (493 分)

3857

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title data-i18n="resources.title_wms"></title>
<style type="text/css">
        .editPane {
            position: absolute;
            right: 10px;
            top: 50px;
            text-align: center;
            background: #FFF;
            z-index: 1000;
            width: 300px;
        }
    </style>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div class='panel panel-primary editPane' id='editPane' style="z-index: 99999">
<div class='panel-heading'>
<h5 class='panel-title text-center' data-i18n="resources.text_wms"></h5>
</div>
<div class='panel-body' id='params'>
<div class='input-group'>
<span style="margin-top: 15px" class='input-group-addon' data-i18n="resources.text_projection"></span>
<select class='form-control selectbtn' id='projectionSelect' name="projectionSelect" onchange="switchProjection()">
<option value="3857">3857</option>
<option value="4326">4326</option>
</select>
</div>
<p>
<div class='input-group'>
<span style="margin-top: 15px" class='input-group-addon' data-i18n="resources.text_wmsVersion"></span>
<select class='form-control selectbtn' id='versionSelect' name="versionSelect" onchange="switchProjection()">
<option value="1.3.0">1.3.0</option>

</select>
</div>
</div>
<div id='mousePositionDiv' class='smCustomControlMousePosition'></div>
</div>
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
<script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
<script type="text/javascript">
    var map, layer, wms1, wms2, wms3, wms4, newHtml, projectionSelect, versionSelect, lastLayer, mapDiv,
        host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var url1 = "http://localhost:8090/iserver/services/map-china400/wms130/China";
    var url2 = "http://localhost:8090/iserver/services/map-china400/wms130/China_4326";
    map = new SuperMap.Map('map', {
        controls: [new SuperMap.Control.Zoom(),
            new SuperMap.Control.Navigation(),
            new SuperMap.Control.ScaleLine(),
            new SuperMap.Control.LayerSwitcher()
        ]
    });
    projectionSelect = document.getElementById("projectionSelect");
    versionSelect = document.getElementById("versionSelect");
    mapDiv = document.getElementById("map");
    switchProjection();
    setposition();
    addHandler(window, "resize", setposition);

    function switchProjection() {
        if (lastLayer) {
            map.removeLayer(lastLayer);
        }
        if (versionSelect.value == "1.3.0") {
            if (projectionSelect.value == "3857") {
                //设置layers图层名称必须是 GetCapabilities 操作返回的文档中声明的Name元素的值,地图图层之间以半角英文逗号进行分隔。最左边的图层在最底,下一个图层放到前一个的上面,依次类推。
                //version,请求版本号。现支持”1.1.1”和”1.3.0”。
                //设置地图的projection,最大显示范围bounds参数
                //初始化WCS图层
                wms1 = new SuperMap.Layer.WMS("WMS1", url1, {
                    layers: "China",
                    version: '1.3.0'
                }, {
                    projection: "EPSG:3857",
                    maxExtent: new SuperMap.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34)
                });
                switchLayer(wms1);
            } else if (projectionSelect.value == "4326") {
                wms2 = new SuperMap.Layer.WMS("WMS2", url2, {
                    layers: "China_4326",
                    version: '1.3.0'
                }, {projection: "EPSG:4326", maxExtent: new SuperMap.Bounds(-180, -90, 180, 90)});
                switchLayer(wms2);
            }
        }
        document.getElementById("mousePositionDiv").innerHTML = newHtml;
    }

    function switchLayer(wms) {
        map.addLayers([wms]);
        var center = new SuperMap.LonLat(0, 0);
        map.setCenter(center, 1);
        lastLayer = wms;
        mapDiv.focus();
        newHtml = resources.text_currentInfo+"<br>" + resources.text_mapProjection + wms.projection + "<br>"+resources.text_currentVersion + wms.params.VERSION;

    }

    function addHandler(element, type, handler) {
        if (element.addEventListener) {
            element.addEventListener(type, handler, false);
        } else if (element.attachEvent) {
            element.attachEvent("on" + type, handler);
        } else {
            element["on" + type] = handler;
        }
    }
    function setposition() {
        var width = map.getSize().w;
        document.getElementById("mousePositionDiv").style.left = width / 2 - 100 + "px";
    }
</script>
</body>
</html>

您把这个直接复制到官网范例中,看4326的能不能正常显示
不行啊,这个里面给的iserver的地址是localhost,我本地没有启动iserver,要改成服务器上的吧

我现在直接访问官网里面的,不改代码,也是错乱的  4326错乱   3857正常

2944254638这个是我的qq号,您加我私聊吧。
...