GetFeaturesByBoundsParameters范围查询,方框就是范围,模式是相交。为什么最后的结果既有旁边横的线,又有旁边竖的线呢。
//pointGeomerty:中心点
//bounds1:查询范围
var bounds1 = new SuperMap.Bounds(pointGeomerty.x - 1, pointGeomerty.y -1, pointGeomerty.x + 1, pointGeomerty.y + 1);
var GetFeaturesByBoundsParameters, getFeaturesByGeometryService;
// 创建矩形图形
var points = [
new SuperMap.Geometry.Point(bounds1.left, bounds1.bottom),
new SuperMap.Geometry.Point(bounds1.left, bounds1.top),
new SuperMap.Geometry.Point(bounds1.right, bounds1.top),
new SuperMap.Geometry.Point(bounds1.right, bounds1.bottom)
];
points.push(points[0]); // 确保多边形闭合
var linearRing = new top.SuperMap.Geometry.LinearRing(points);
var polygonFeature = new top.SuperMap.Feature.Vector(new SuperMap.Geometry.Polygon([linearRing]));
// 将查询范围作为矩形添加到地图上
crossLayer.addFeatures(polygonFeature);
GetFeaturesByBoundsParameters = new SuperMap.REST.GetFeaturesByBoundsParameters({
datasetNames: [Freedom.App.prefix.replace("@", '') + ":" + roadTable],
spatialQueryMode: SuperMap.REST.SpatialQueryMode.INTERSECT,
bounds: bounds1
});
getFeaturesByGeometryService = new SuperMap.REST.GetFeaturesByBoundsService(dataUrl, {
eventListeners: {
"processCompleted": queryCompleted,
"processFailed": processFailed
}
});
getFeaturesByGeometryService.processAsync(GetFeaturesByBoundsParameters);