Openlayers样式不适用于某些Geoserver WFS图层(块状)

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

我想使用OpenLayer更改geoserver WFS图层的样式。问题是,有一层可以更改样式,但是有其他层不能更改。

使用此代码

style: new ol.style.Style({
                image: new ol.style.Circle({
                    stroke: new ol.style.Stroke({
                        color: 'rgba(255, 0, 0, 1.0)',
                        width: 5
                    }),
                    radius: 5
                })
            })

我可以将这一层(SRID:4326)更改为这样

enter image description here

但是该样式不能应用于具有SRID的另一层:32663。无论我尝试哪种样式(描边,填充,颜色,图像),它都将始终像这样显示(块形状)

enter image description here

我从PostgreSQL数据库导入了这些层。查看几何投影,成功更改的图层具有如下点状形状

SELECT ST_AsEWKT(geometry) FROM "table1" LIMIT 1;
result : SRID=4326;POINT(126.8865913 37.2598192)

geom sample : "0101000020E6100000C39A6FE9BDB85F40BB6F6BC141A14240"

enter image description here

同时未成功更改的层具有像这样的块状形状

SELECT ST_AsEWKT(geometry) FROM "table2" LIMIT 1;
result : SRID=32663;MULTIPOLYGON(((14240035.8111278 4485667.02788355,14239940.2255882 4485585.20329766,.........

geom sample : "0106000020977F00000100000001030000000100000005000000CDA1878968066B41EE70C72749445141284876F45D066B418F4696B13144514100B1FC4552066B41989893F24644514160E00CDB5C066B415B95DD685E445141CDA1878968066B41EE70C72749445141"

enter image description here

openlayers openlayers-3 geoserver web-feature-service
1个回答
0
投票

问题是第一层要素几何类型为Point,因此上述样式代码将起作用。

但是,另一层几何类型是多边形/多多边形,因此根据https://embed.plnkr.co/plunk/GvdVNE,不同的类型将需要不同的代码。以下代码适用于多边形样式。

var polyStyle = new ol.style.Style({
    stroke: new ol.style.Stroke({
        color: 'rgb(0,255,255)',
        width: 3
    }),
    fill: new ol.style.Fill({
        color: 'rgba(0, 255, 255, 0.5)'
    })
})
© www.soinside.com 2019 - 2024. All rights reserved.