相当于服务地址中的query查询
获取图层范围内的数据4.24
import Query from '@arcgis/core/rest/support/Query';
import * as QueryTask from "@arcgis/core/rest/query";
//获取图层范围内的数据4.24
_returnFeatureFromWhere(url, where, geo) {
const self = this
return new Promise((resolve, reject) => {
const queryObject = new Query();
queryObject.returnGeometry = true;
queryObject.outFields = ["*"];
queryObject.where = where
queryObject.geometry = geo ? geo : null;
queryObject.outSpatialReference = self.mapView.spatialReference
QueryTask.executeQueryJSON(url, queryObject)
.then(response => {
resolve(response)
})
.catch((err) => {
console.log("_returnFeatureFromWhere异常:", err);
});
})
},
获取图层范围内的数据4.18
//以下下代码放到初始化加载
const self = this
require(["esri/tasks/QueryTask","esri/tasks/support/Query"], function(QueryTask,Query) {
self.QueryTask = QueryTask
self.Query = Query
});
//获取图层范围内的数据4.18
_returnFeatureFromWhere(url, where, geo) {
const self = this
return new Promise((resolve, reject) => {
const query = new self.Query();
query.returnGeometry = true;
query.outFields = ["*"];
query.where = where
query.geometry = geo ? geo : null;
query.outSpatialReference = self.mapView.spatialReference
const queryTask = new self.QueryTask(url);
queryTask.execute(query)
.then(response => {
resolve(response)
})
})
},
注意新旧版本的Query的变化!!!