我是靠谱客的博主 柔弱曲奇,最近开发中收集的这篇文章主要介绍arcgis js api通过StatisticDefinitions实现对动态服务中管线图层长度统计求和,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
<!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 js api通过StatisticDefinitions实现对动态服务中管线图层长度统计求和所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复