arcgis javascript api学习3

Class: QueryTask  

Description

Executes a query operation on a layer resource of a map service exposed by the ArcGIS Server REST API
(在基于ArcGIS Server REST API发布的地图服务的一个图层资源上执行一个查询操作).
 ------------------------------------------------------------------------------------
  Code snippets:(代码片段)
var queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0");
Code snippets:
var query = new esri.tasks.Query();
query.where = "STATE_NAME = 'Washington'";
query.outSpatialReference = {wkid:102100}; 
query.returnGeometry = true;
query.outFields = ["CITY_NAME"];
queryTask.execute(query, addPointsToMap);
 ----------------------------------------------------------------------------------
 execute(parameters, callback?, errback?)
Executes a Query against an ArcGIS Server map layer(执行针对ArcGIS Server Map Layer的查询). The result is returned as a FeatureSet(结果作为FeatureSet返回)
If the query is successful, the user-specified callback function is invoked with the result(如果查询成功了,用户自定义的函数被触发,这个函数返回一个FeatureSet).
FeatureSet contains an array of Graphic features(一个FeatureSet包含一个Graphic集合), which can be added to the map using Map.graphics.add()
This array will not be populated if no results are found.
The return object of dojo.Deferred was added at v1.4.
Return value: dojo.Deferred
Input Parameters:
<Queryparameters   Required   Specifies the attributes and spatial filter of the query.
<Function> callback     Optional   The argument passed to the callback function, which is a FeatureSet.
<Function> errback   Optional   An error object is returned if an error occurs on the Server during task execution. (As of v1.3)
Code snippets:
var query = new esri.tasks.Query();
query.where = "STATE_NAME = 'Washington'";
query.outSpatialReference = {wkid:102100}; 
query.returnGeometry = true;
query.outFields = ["CITY_NAME"];
queryTask.execute(query, addPointsToMap);
------------------------------------------------------------------------------------
 __________________________________________________________________________________________________________________________
Class: Query  

Description dojo.require("esri.tasks.query")

Query for input to the QueryTask(Query作为QueryTask的输入参数). Not all query properties are required to execute a QueryTask
(在执行一个QueryTask中并不是所有的查询属性都是必须的). The query definition requires one of the following properties: queryGeometry, text, or where
(Query的定义中至少需要如下属性之一:queryGeometry,text,或者where). Optional properties include outFieldsoutSpatialReference, and returnGeometry
(可选的属性包括 outFields,outSpatialReference,和returnGeometry).
______________________________________________________________________________________________________________________________
Class: FeatureSet  

Description

A collection of features returned from ArcGIS Server or used as input to tasks. Each feature in the FeatureSet may contain geometry, attributes, symbolgy, and
an InfoTemplate(每个在FeatureSet中的feature包含几何形状,属性,符号和infotemplate). If the FeatureSet does not contain geometry, and only contains attributes,
the FeatureSet can be treated as a table where each feature is a row object. Tasks that return FeatureSet include QueryTaskGeoprocessor, and RouteTask(返回FeatureSet的任务包括QueryTask,Geoprocessor,RouteTask). In addition, Geoprocessor and RouteTask may require FeatureSet as input.

Class hierarchy

esri.tasks.FeatureSet

****************************************************************************************************************************

根据zhyxk的数据库结构提出如下解决方案:

1、javascript调用webservice获取查询到的dataset并获取四个角点坐标作为graphic添加到map默认的graphiclayer上(期间还考虑过javascript函数和C#函数之间的数据传递问题,

相当于javascript间接获取webservice返回的dataset)

2、使用query和querytask查询mapservice中的某个layer得到的结果也是作为graphic添加到map默认的graphiclayer上(前提是要准备好参与查询的mapservice)


原文地址:https://www.cnblogs.com/zhangjun1130/p/1956776.html