我是靠谱客的博主 柔弱曲奇,这篇文章主要介绍arcgis js api通过StatisticDefinitions实现对动态服务中管线图层长度统计求和,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>QueryTask with geometry, results as an InfoWindow onClick</title> <link rel="stylesheet" href="http://localhost:8080/arcgis_js_api/library/3.27/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="http://localhost:8080/arcgis_js_api/library/3.27/esri/css/esri.css"> <script src="http://localhost:8080/arcgis_js_api/library/3.27/init.js"></script> <script> require([ "esri/tasks/QueryTask", "esri/tasks/query", "esri/SpatialReference", "esri/geometry/webMercatorUtils","esri/geometry/geometryEngine", "esri/tasks/StatisticDefinition", ], function (QueryTask, Query, SpatialReference, webMercatorUtils,geometryEngine,StatisticDefinition) { var queryTask = new QueryTask( "http://localhost:6080/arcgis/rest/services/gx/MapServer/0"); var sumLength = new StatisticDefinition(); //设置统计类型为求和 sumLength.statisticType = "sum"; //设置要统计的字段 sumLength.onStatisticField = "SHAPE_Length"; //设置统计后输出的字段(自定义) sumLength.outStatisticFieldName = "sumLength"; var query = new Query(); query.outFields = ["SHAPE_Length"]; //全部查询sumLength query.where = "1=1"; //设置统计属性为 query.outStatistics =[sumLength]; //执行查询 queryTask.execute(query, function (results) { if (results) { var sumlen = results.features[0].attributes.sumLength; console.log(sumlen) } }) }); </script> </head> <body class="claro"> Single click a county in South Carolina to get more information. <div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div> </body> </html>

 

最后

以上就是柔弱曲奇最近收集整理的关于arcgis js api通过StatisticDefinitions实现对动态服务中管线图层长度统计求和的全部内容,更多相关arcgis内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(48)

评论列表共有 0 条评论

立即
投稿
返回
顶部