首页 / 浏览问题 / WebGIS / 问题详情
iclient for classic 加载wms130错乱问题
2EXP 2020年09月08日

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

1个回答

您好,请问您那边具体的错误是什么,我这边测试了一下是都能正常显示预览的。
2,248EXP 2020年09月08日

上面1,2两张有代码的图片可以点击查看大图,里面有展示出来错乱的效果,这个是同一个iserver发布的同一幅地图,使用classic 脚本库加载地图,就会错乱
目前就是不太明白为什么会显示错乱,是否是加载代码的参数写的不正确

您的第二张图是在classic下的4490坐标系有这种情况,还是其他的3857和4326坐标系也有这种情况?
3857和4326下直接就无法显示地图,改了epsg之后,上下左右的坐标,还有中心点的坐标也进行了相应的修改,都是参照第3张图片里面的圈起来的部分填写的

您使用官网范例https://iclient.supermap.io/examples/classic/editor.html#OGC_wms,看调用您的wms服务在3857和4326这两个坐标系是否能正常显示。

4326

3857的可以显示,上边说的无法显示可能是刚才测试的时候,参数有误

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号,您加我私聊吧。
...