您好!传入的查询对象必须是单个的geometry,不能是多个;但是可以将多个 polygon合并为一个再查询。我这里以leaflet为例,使用truf合并polygon做几何查询。具体可以参考代码:
// 创建包含多个Polygon的LayerGroup
var polygonGroup = L.layerGroup().addTo(map)
var polygon = L.polygon(
[
[0, 0],
[-30, 0],
[-10, 30],
[0, 0]
],
{ color: 'red' }
).addTo(polygonGroup)
var polygon1 = L.polygon(
[
[0, 0],
[30, 0],
[10, 30],
[0, 0]
],
{ color: 'blue' }
).addTo(polygonGroup)
// 使用Turf.js合并多个Polygon为一个MultiPolygon
var polygonFeatures = polygonGroup.toGeoJSON().features
var unionFeature = turf.union(...polygonFeatures)
var geometryParam = new L.supermap.GetFeaturesByGeometryParameters({
datasetNames: ['World:Countries'],
geometry: unionFeature,
spatialQueryMode: 'INTERSECT'
})
new L.supermap.FeatureService(url).getFeaturesByGeometry(geometryParam, function (serviceResult) {
resultLayer = L.geoJSON(serviceResult.result.features, {
onEachFeature: function (feature, layer) {
layer.bindPopup('country' + ':' + feature.properties.COUNTRY)
}
}).addTo(map)
})
希望可以帮助到您!