首页 / 浏览问题 / WebGIS / 问题详情
iclient 多面叠加成一个面,迭代怎么写
55EXP 2022年07月21日

想将4个面叠加成一个面,但是由于异步的原因下面代码不能迭代成功,有没有解决方案,好像迭代的结果只能在回调函数里面生效

<script type="text/javascript">

    map = L.map('map', {
        crs: L.CRS.EPSG4326,
        center: [40, 117],
        maxZoom: 18,
        zoom: 8
    });

    var 空间分析url="http://localhost:8090/iserver/services/spatialAnalysis-ChengDuShengXian/restjsr/spatialanalyst"


    function UNION (s,o,url) {
        var GeometryOverlayAnalystParameters= new SuperMap.GeometryOverlayAnalystParameters({
            sourceGeometry: s,
            operateGeometry: o,
            operation: SuperMap.OverlayOperationType.UNION
        })
        L.supermap.spatialAnalystService(url).overlayAnalysis(GeometryOverlayAnalystParameters, function (serviceResult) {
                    base=serviceResult.result.resultGeometry

        })


    }


    var base = {
        "type": "Feature",
        "geometry": {
            "type": "Polygon",
            "coordinates": [[[116.25, 40.25],
                [116.25, 39.75],
                [117.25, 39.75],
                [117.25, 40.25],
                [116.25, 40.25]]]
        }
    };
    var l1 = {
        "type": "Feature",
        "geometry": {
            "type": "Polygon",
            "coordinates": [[[116.75, 40.25],
                [116.75, 39.75],
                [117.75, 39.75],
                [117.75, 40.25],
                [116.75, 40.25]]]
        }
    };
    var l2 = {
        "type": "Feature",
        "geometry": {
            "type": "Polygon",
            "coordinates": [[[116.75, 39.75],
                [117.25, 39.75],
                [117.25, 40.75],
                [116.75, 40.75],
                [116.75, 39.75]]]
        }
    };

    var l3 = {
        "type": "Feature",
        "geometry": {
            "type": "Polygon",
            "coordinates": [[[116.75, 40.25],
                [116.75, 39.25],
                [117.25, 39.25],
                [117.25, 40.25],
                [116.75, 40.25]]]
        }
    };



    UNION(base,l1,空间分析url)
    UNION(base,l2,空间分析url)
    UNION(base,l3,空间分析url)
    L.geoJSON(base).addTo(map);


    
    
</script>-->

...