很多面对象union分析变成一个面,如何写循环实现
<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>-->
这样迭代由于异步的原因不能成功,有没有解决方案
你如果是已知你面的数量,也就是需要迭代的次数,可以直接在一个里去写循环的。
或者可以参考这个demo:https://iclient.supermap.io/examples/leaflet/editor.html#04_geometryOverlayBatchAnalystService