ArcGIS、SuperMap Javascript API for Leaflet 关于查询的总结
开源GIS插件比如Leaflet、OpenLayers等基本上能完成绝大部分功能,但是遇到图层数据的属性查询、空间查询这部分就有点吃力了,GIS服务厂商一般都会基于自家的服务结合开源插件开发一些定制功能,比如超图公司的SuperMap Javascript API for Leaflet、SuperMap Javascript API for Openlayers、ArcGIS Javascript API for Leaflet等等。
ArcGIS API
接口 :
L.esri.Query
构造:
L.esri.query(<Object> options)
L.esri.query(<FeatureLayerService> endpoint)
L.esri.query(<MapService> endpoint)
L.esri.query(<ImageService> endpoint)
属性查询:
var query = L.esri.query({
url:'https://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/stops/FeatureServer/0'
});
query.where("zone_id='B'").bounds(function(error, latLngBounds, response){
map.fitBounds(latLngBounds);
});
空间查询:
var southWest = L.latLng(45.51, -122.70);
var northEast = L.latLng(45.52, -122.64);
var bounds = L.latLngBounds(southWest, northEast);
var query = L.esri.query({
url:'https://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/stops/FeatureServer/0'
});
query.within(bounds); //within,还有其他的within\contains\intersects\bboxIntersects\overlap\nearby
query.run(function(error, featureCollection, response){
console.log('Found ' + featureCollection.features.length + ' features');
});
另外,还有其他的几个接口也可以完成查询任务
L.esri.Find
L.esri.IdentifyFeatures
L.esri.IdentifyImage
SuperMap API
接口:
L.supermap.queryService
构造:
L.supermap.queryService(url,<options>)
url - 地图查询服务访问地址
options - 服务交互时所需的可选参数。如:
serverType - {SuperMap.ServerType} 服务来源 iServer|iPortal|online
属性查询:
queryBySQL(params, callback, resultFormat) 地图SQL查询服务
params SuperMap.QueryBySQLParameters SQL查询相关参数类
callback function 回调函数
resultFormat SuperMap.DataFormat 返回结果类型
var param = new SuperMap.QueryBySQLParameters({
queryParams: {
name: "Capitals@World.1",
attributeFilter: "SMID < 10"
}
});
L.supermap.queryService("http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/World").queryBySQL(param, function (serviceResult) {
var result = serviceResult.result;
resultLayer = L.geoJSON(result.recordsets[0].features).addTo(map);
});
空间查询:
queryByGeometry(params, callback, resultFormat) 地图几何查询服务
params SuperMap.QueryByGeometryParameters Geometry查询相关参数类
callback function 回调函数
resultFormat SuperMap.DataFormat 返回结果类型
var polygon = L.polygon([[0, 20], [-30, 20], [-10, 50], [0, 20]], {color: 'red'});
var param = new SuperMap.QueryByGeometryParameters({
queryParams: {name: "Capitals@World.1"},
geometry: polygon
});
L.supermap.queryService("http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/World").queryByGeometry(param, function (serviceResult) {
var result = serviceResult.result;
resultLayer = L.geoJSON(result.recordsets[0].features).addTo(map);
});
queryByDistance(params, callback, resultFormat) 地图距离查询服务
params SuperMap.QueryByDistanceParameters Distance查询相关参数
callback function 回调函数
resultFormat SuperMap.DataFormat 返回结果类型
var circleMarker = L.circleMarker([30, 104], {color: 'red'});
var param = new SuperMap.QueryByDistanceParameters({
queryParams: {name: "Capitals@World.1"},
distance: 10,
geometry: circleMarker
});
L.supermap.queryService("http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/World").queryByDistance(param, function (serviceResult) {
var result = serviceResult.result;
resultLayer = L.geoJSON(result.recordsets[0].features).addTo(map);
});
queryByBounds(params, callback, resultFormat) bounds查询地图服务
params SuperMap.QueryByBoundsParameters 通过Bounds查询的相关参数类
callback function 回掉函数
resultFormat SuperMap.DataFormat 返回结果类型
var polygon = L.polygon([[0, 0], [39, 0], [39, 60], [0, 60], [0, 0]]);
var param = new SuperMap.QueryByBoundsParameters({
queryParams: {name: "Capitals@World.1"},
bounds: polygon.getBounds()
});
L.supermap.queryService("http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/World").queryByBounds(param, function (serviceResult) {
var result = serviceResult.result;
resultLayer = L.geoJSON(result.recordsets[0].features).addTo(map);
});
转载自:https://blog.csdn.net/fengyekafei/article/details/79885102