Leaflet 传单WMS瓷砖层边界集

Leaflet 传单WMS瓷砖层边界集,leaflet,geoserver,react-leaflet,Leaflet,Geoserver,React Leaflet,我想用一个区域限制我的wms平铺层。我在WMSTileLayer边界中看到了一个参数,但是它不可用—它总是给出一个错误lat long TypeError: Cannot read property 'lat' of undefined 看起来wms瓷砖层与坐标不重叠。我在下面设置了srs选项 <WMSTileLayer layers={tile.layer} format='image/png8' version='1.3' url={tile.u

我想用一个区域限制我的wms平铺层。我在WMSTileLayer边界中看到了一个参数,但是它不可用—它总是给出一个错误lat long

TypeError: Cannot read property 'lat' of undefined
看起来wms瓷砖层与坐标不重叠。我在下面设置了srs选项


  <WMSTileLayer
    layers={tile.layer}
    format='image/png8'
    version='1.3'
    url={tile.url}
    tiled={true}
    bounds={tile.bounds}
    time={tile.date}
    transparent={true}
    zIndex={tile.zIndex}
    srs={CRS.EPSG4326}
  />

图中可以显示Geoserver配置


感谢您的帮助。

WMSTileLayer继承自L.TileLayer,后者继承自L.GridLayer。
bounds
选项是的一个实例,但它是一个数字数组。您需要从您的边界:

const{bounds}=tile
//界限:
// [
//  [27.5, 37.5],
//  [28.24, 37.9]
// ]
常数latLng1=L.latLng(界[0]);
常数latLng2=L.latLng(界[1]);
常量myLatLngBounds=L.latLngBounds(latLng1,latLng2);
现在,您可以在WMSTileLayer的
边界
道具中使用它:



Hi@Seth,我试过这个。但是它不起作用。实际上我知道边界可以用作数组,比如映射边界,我们可以将latlongbounds作为数组。此外,Typescript还可以将此对象转换为latlngbounds类。你对这个话题有什么建议吗。我观察到wms是精确的,但是传单覆盖了地图的边界。当你说它不工作时,你的意思是你仍然得到同样的错误?你能把错误堆栈跟踪添加到问题中吗?不,错误不存在,但是边界是随着映射边界而变化的,而不是我给出的。好吧……听起来像是一个完全不同的问题。如果不了解设置的全部范围,我就无法真正诊断该问题。也许您可以添加更多代码,或者在codepen/codesandbox中重现问题
      bounds: [
        [27.5, 37.5],
        [28.24, 37.9]
      ]