跨域问题 听说可以用代理完成 找了一堆解释 发现没用

0 投票
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="dist/leaflet/include-leaflet.js"></script>
</head>

<body style="margin: 0;overflow: hidden;background: #fff;width: 100%;height: 100%;position: absolute;top: 0">
    <!-- 添加承载地图控件的容器 -->
    <div id="map" style="margin:0 auto;width: 100%;height:100%"></div>
    <script>
        var url = "http://192.168.48.119:8081/geoesb/proxy/services/maps/rest/e6e566a91e78468fabbc9c531a057da6/886e60bb7e014f22a707de23e6f6505d";
        // var res = [611.496226281409, 305.748113140706,
        //     152.874056570352, 76.4370282851762,
        //     38.2185141425882, 19.1092570712941,
        //     9.55462853564703, 4.77731426782351];
        map = L.map("map", {
            center: [ 85962.17 , 2689538.35],
            maxZoom: 18,
            zoom: 2,
            crs: new L.Proj.CRS("EPSG:3857", {
                origin: [7844.058, 2882954.0],
                // resolutions: res,
                bounds: L.bounds([83277.55 , 2684582.55], [188643.65 , 2694908.33])
            })
        })
        L.supermap.tiledMapLayer(url, {noWrap: true}).addTo(map);

        layerService();

    function layerService() {
        L.supermap
            .layerInfoService(url)
            .getLayersInfo(function (serviceResult) {
                var result = serviceResult.result;
                var innerHTML = "";
                result.subLayers.layers.map(function (layer) {
                    innerHTML += layer.name + "<br>";
                });
                infowin = L.popup({maxWidth: 1000})
                    .setLatLng(map.getCenter())
                    .setContent(innerHTML)
                    .openOn(map);
            });
    }
    </script>
</body>

<ml>

10月 26, 2020 分类:  123次浏览 | 用户: 木大木大 初出茅庐 (43 分)

1个回答

0 投票
你好,请问你的iserver版本和iclient版本是多少。
10月 27, 2020 用户: 张亮 名扬四海 (2,395 分)

10的    是不是要配置L.supermap.layerInfoService  怎么配置的

您的代码中只是调用了地图服务的url进行出图是吧,是不需要设置layerInfoService的,您说的跨域,是您这iserver开启了https协议还是想代理一个其他端口?
...