CSS Style是GeoServer的一个扩展插件,使用CSS写起来的地图渲染策略文件相比较SLD而言,非常的简洁,本文根据GeoServer用户手册,稍微改写,便于该知识点的推广。
一 CSS Style安装
1 从geoserver下载页面下载 对应版本的geoserver-A.B.C-css-plugin.zip。A.B.C对应的是GeoServer的版本号。
2 解压geoserver-A.B.C-css-plugin.zip,将解压后的jar文件,复制到对应geoserver版本的WEB-INF/lib目录中。
3 重启GeoServer即可。
在新建Style页面看到Format有CSS选项即代表可以正常使用了。
新建CSS Style.png
二 CSS应用基础
CSS Style和SLD一样是一个地图渲染策略文件,新建样式,绑定图层等操作和sld是一模一样的,只是写起来更加简洁。
SLD的策略文件举例如下:
version="1.0.0"
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"
xmlns:gml="http://www.opengis.net/gml"
xsi:schemaLocation="http://www.opengis.net/sld
http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd
">
USA states population
population
Population in the United StatesA sample filter that filters the United States into three
categories of population, drawn in different colors
< 2M