iClient for Leaflet 的缓冲区查询示例问题

0 投票

示例网址为https://iclient.supermap.io/examples/leaflet/editor.html#04_bufferAnalystService

示例缓冲区分析为线的缓冲区,我想做一个点的缓冲区,已经将BufferSetting中左边长度删去,也设置成了圆形的缓冲区形状,还将代码中的url改为自己的huanchongurl,将World:Capitals改为Chemical_Factory@EmergDS,把sql条件改为"Name='铝业化工厂'"

但是还是没有效果,不知道是什么原因,我的地图发布是按照经纬度的,而缓冲区是按米的,是不是这个原因?该如何更改?

改后代码为


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title data-i18n="resources.title_bufferAnalystService"></title>
<script type="text/javascript" src="../js/include-web.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 type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
<script >
		var y="http://localhost:8090/iserver/services/map-1/rest/maps/City@EmergDS   ";
			var dataUrl="http://localhost:8090/iserver/services/data-1/rest/data";
			
		    map = L.map('map', {
		        center: [ 30.61,103.7 ],
		        maxZoom: 50,
		        minZoom: 1,
		        zoom: 14,
				zoomControl:false,
				
				
		    });
			
		    L.supermap.tiledMapLayer(y).addTo(map);
		    
		 bufferAnalystProcess();

    function bufferAnalystProcess() {
      var huanchongurl="http://localhost:8090/iserver/services/spatialAnalysis-1/restjsr/spatialanalyst";
      
		
        dsBufferAnalystService = L.supermap.spatialAnalystService(huanchongurl);
        dsBufferAnalystParameters = new SuperMap.DatasetBufferAnalystParameters({
            dataset: "Chemical_Factory@EmergDS",
            filterQueryParameter: new SuperMap.FilterParameter({
                attributeFilter: "Name='铝业化工厂'"
            }),
            bufferSetting: new SuperMap.BufferSetting({
                endType: SuperMap.BufferEndType.ROUND,
                leftDistance: {value: 100},
           
                semicircleLineSegment: 10
            })
        });
        dsBufferAnalystService.bufferAnalysis(dsBufferAnalystParameters, function (serviceResult) {
            var result = serviceResult.result;
            resultLayer = L.geoJSON(result.recordset.features, {color: "red"}).addTo(map);
        });

    }
</script>
</body>
</html>

服务什么的都是发了的。

4月 18 分类:  160次浏览 | 用户: 大小老鬼 初出茅庐 (45 分)

1个回答

0 投票
 
已采纳

同时在打开的网页里可以查看到recordset不存在和一个400错误,400错误打开显示数据集不存在,可以上面图片可以看到已经发在数据服务里了。

4月 19 用户: 大小老鬼 初出茅庐 (45 分)
采纳于 4月 20 用户:大小老鬼

你好,将服务地址改为http://localhost:8090/iserver/services/spatialAnalysis-1/restjsr/spatialanalyst/datasets/Chemical_Factory%40EmergDS后没有上面那个错误了,但是打开出现一个新的404错误,找不到原因,麻烦解答一下,

附上404错误和代码

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title data-i18n="resources.title_bufferAnalystService"></title>
<script type="text/javascript" src="../js/include-web.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 type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
<script >
		var y="http://localhost:8090/iserver/services/map-1/rest/maps/City@EmergDS   ";
			var dataUrl="http://localhost:8090/iserver/services/data-1/rest/data";
			
		    map = L.map('map', {
		        center: [ 30.61,103.7 ],
		        maxZoom: 50,
		        minZoom: 1,
		        zoom: 14,
				zoomControl:false,
				
				
		    });
			
		    L.supermap.tiledMapLayer(y).addTo(map);
		    
		 bufferAnalystProcess();

    function bufferAnalystProcess() {
      var huanchongurl="http://localhost:8090/iserver/services/spatialAnalysis-1/restjsr/spatialanalyst/datasets/Chemical_Factory%40EmergDS";
      
		
        dsBufferAnalystService = L.supermap.spatialAnalystService(huanchongurl);
        dsBufferAnalystParameters = new SuperMap.DatasetBufferAnalystParameters({
            dataset: "Chemical_Factory@EmergDS",
            filterQueryParameter: new SuperMap.FilterParameter({
                attributeFilter: "Name='铝业化工厂'"
            }),
            bufferSetting: new SuperMap.BufferSetting({
                endType: SuperMap.BufferEndType.ROUND,
                leftDistance: {value: 100},
           
                semicircleLineSegment: 10
            })
        });
        dsBufferAnalystService.bufferAnalysis(dsBufferAnalystParameters, function (serviceResult) {
            var result = serviceResult.result;
            resultLayer = L.geoJSON(result.recordset.features, {color: "red"}).addTo(map);
        });

    }
</script>
</body>
</html>

解决了,谢谢
你好,我碰到了相同的问题,请问楼主是怎么解决的?谢谢
...