ArcGIS API for JavaScrip一些概念

来源:B站

1.任务

ArcGIS API for JavaScript中执行多种类型的任务。所有的任务都是通过esri/tasks资源进行访问的

ClosestFacilityTask ,ConfigurationTask ,FindTask ,GeometryService,Geoprocessor , ldentifyTask ,ImageServiceldentifyTask , JobTask,Locator,NotificationTask,PrintTask ,QueryTask,ReportTask ,RouteTask , ServiceAreaTask ,TokenTask ,WorkflowTask

2.什么是promise

一个promise代表一个操作完成的最终返回值的对象
promise有以下特点:
-可以为三个状态中的一个: pending、resolved、rejected
-可以从unfulfilled转变到resolved或者rejected
-实现了一个then()方法来注册回调函数
someAsyncFunction().then(callback, errback);
回调不能改变promise产生的值
-promise的then()方法可以返回一个新的promise,可进行链式操作

3.查询、定位、查找

3.1查询

模式:查询参数>查询任务>查询结果
Query>QueryTask>多种形式
查询类型:属性查询、空间查询、统计查询

3.1.1属性查询:

可以通过两个属性设置查询条件:Query.where和Query.text
var query = new Query ();
query.where = “STATENAME= ‘Washington’”;
query.text = “Washington”; 这个只能查询默认字段,不能查询其他字段
在这里插入图片描述

3.1.2空间查询:

通过Query.geometry + Query.spatialRelationship 指定查询条件
Geometry,Extent , Multipoint , Point , Polygon , Polyline,spatialRelationship,lntersects, contains, crosses, envelope-intersects, index-intersects, overlaps, touches, within, relation

var polygon = new Polygon({
rings: rings
});
var query = new Query ();
query. geometry = polygon;
query.spatialRelationship = “intersects” ;
可选参数:Query.distance和Query.units

3.1.3统计查询

通过Query.outStatistics定义参数
//query for the sum of the population in all features。查询所有要素的人口总数
var sumPopulation = {
onStatisticField:“POP_2015”,// service field for 2015 population //统计字段
outstatisticrieldName:“Pop_2015_sum”, //统计结果字段
statisticType: “sum” //统计类型
};
//Notice that you can pass a sLexpression as a field name to calculate statistics。请注意,您可以传递一个sLexpression作为字段名来计算统计信息
var populationchangeDefinition = {
onStatisticField:“POP_2015 - POP_2010”,// service field for 2015 population
outstatisticrieldName: “avg_pop_change_2015_2010” ,
statisticType: “avg”
};
var query = new Query ();
query.outstatistics = [sumPopulation,populationChangeDefinition]; //传入数组

3.2定位

输入>任务>输出
IdentifyParameters>IdentifyTask>IdentifyResult

定位-ldentifyParameter
IdentifyParameter对象可以为定位操作设置多个属性:

  • geometry
  • layerlds
  • layerOption
  • tolerance
  • returnGeometry

    //set the parameters for the Identify
    params = new IdentifyParameters();
    params.geometry = event.mapPoint;
    params.layerIds = [o,1,2];
    params.layeroption = “visible” ;
    params.tolerance = 3;
    params.mapExtent = view.extent;

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3.3查找

查找-FindParameters
输入>任务>输出
FindParameters>FindTask>FindResult

FindParameters对象为查找操作指定搜索条件:

  • layerlds
  • searchFields
  • searchText
  • returnGeometry
  • contains
    var params = new FindParameters ();
    params.layerIds = [0];
    params.searchFields =[“areaname”];
    params.searchText = document.getElementById(“inputTxt”).value;

创建FindTask对象
//create a FindTask pointing to a map service
var find = new FindTask({
url: “https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/Map”
});

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
Query,Identify 和Find比较
在这里插入图片描述

4地理处理任务

首先需要一个地理处理模型
地理处理模型:arcMap中Toolboxes工具箱,每个工具都可以称为地理处理模型。
在这里插入图片描述
发布地理处理模型及使用。
在这里插入图片描述

输入>任务>输出
对象>Geoprocessor>ParameterValue
对象:构建地理处理模型时指定都输出参数。
需要知道的三件事
①地理处理服务URL地址
②输入和输出参数
③任务是同步的还是异步的

同步任务
-任务执行时,使用者必须等待执行的结果;
-使用Geoprocessor.execute()方法提交作业;
-执行结果保存在ParameterValue数组中;
异步任务
-提交作业后,执行结果返回前其他功能还可以继续执行;
-使用Geoprocessor.submitJob()方法提交作业;
在这里插入图片描述
服务详情页面
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值