我如何缩放到cql_filter功能?

问题描述 投票:1回答:1

我正在使用geoserver。我写下面的代码;

const mywms = L.tileLayer.wms("http://localhost:8080/geoserver/taj/wms", {
    layers: 'taj:country',
    format: 'image/png',
    CQL_FILTER: 'name=pana'
    transparent: true,
    opacity: 0.4,
    version: '1.1.0',
    attribution: "country layer"
});

一切都很好。图层被过滤。但是我需要选择的功能来放大全部范围。我尝试使用此代码将mywms层居中; map.fitBounds(mywms.GetBounds());。但是它显示了错误; mywms.getBOunds is not a function。有帮助吗?

leaflet geoserver wms
1个回答
0
投票

正如注释中所指出的,WMS请求在请求中包含地图的边界框,因此将始终覆盖整个地图区域。

要获得单个功能的范围,您需要制作一个WFS request,其中包括过滤器,然后在返回时放大至该功能的范围。

© www.soinside.com 2019 - 2024. All rights reserved.