我正在将简单样式应用于 VectorTile 图层。特征加载并以所述样式显示。
我面临的问题是落入瓦片边缘(或接近)的特征似乎在瓦片限制处被“切割”。
我尝试declutter: true
在定义中使用该选项ol.layer.VectoTile
,这有帮助,但某些功能消失了(好像它正在进行一些聚类),对于我的用例,即使图标出现在顶部,我也需要查看所有功能另一个。
我不太明白为什么会发生这种情况,因为样式是在客户端而不是在服务器上完成的。
有没有办法可以使用 VectorTiles 完成这项工作?
我正在使用的代码:
const layer = new ol.layer.VectorTile({
style: vectorStyle,
//declutter: true,
source: new ol.source.VectorTile({
tileGrid: ol.tilegrid.createXYZ({maxZoom: 19}),
format: new ol.format.MVT(),
url: `https://<geoserver_host>/gwc/service/tms/1.0.0/${layer_name}@${matrix_set}@pbf/{z}/{x}/{-y}.pbf`,
}),
});
map.addLayer(layer);
更多信息:源数据存储在带有 PostGIS 扩展的 PostgreSQL 数据库中。GeoServer 生成矢量切片并通过 TMS 服务交付它们
编辑:我发现问题是因为图层的默认样式是自定义样式,它使用外部图像作为图标:
<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<Name>icon</Name>
<UserStyle>
<!-- Styles can have names, titles and abstracts -->
<Title>Icon</Title>
<FeatureTypeStyle>
<Rule>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource xlink:type="simple" xlink:href="https://<host_url>/${icon_type}/${level}.png" />
<Format>image/png</Format>
</ExternalGraphic>
<Size>24</Size>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
将默认样式设置为默认“点”解决了这个问题。但我不知道为什么在使用 Vector Tiles 时它不会使用默认的服务器样式,而是客户端提供的样式 有人能解释一下为什么 GeoServer 会发生这种情况吗?