一、gwc发布地图切片步骤
准备好切片数据,对gwc进行配置,如下:
- Geowebcache安装
Geowebcache解压缩在tomcat下的webapps文件夹中,随tomcat启动而起动,端口同tomcat端口
- Geowebcache配置
修改web-inf文件夹下的文件web.xml,在</context-param>节点后添加如下节点(实际切片路径)
<context-param>
<param-name>GEOWEBCACHE_CACHE_DIR</param-name>
<param-value>E:\\cityMap\\XiAnCacheTiles</param-value>
</context-param>
重启服务之后,进入E:\cityMap\XiAnCacheTiles目录下,修改生成的geowebcache.xml文件,在<layers>…</layers>节点中添加如下节点(加入有三个图层)
<arcgisLayer>
<name>xaAnno</name>
<tilingScheme>E:\\cityMap\\XiAnCacheTiles\\xaAnno\\Conf.xml</tilingScheme>
<tileCachePath>E:\\cityMap\\XiAnCacheTiles\\xaAnno\\_alllayers\\</tileCachePath>
</arcgisLayer>
<arcgisLayer>
<name>xaMap</name>
<tilingScheme>E:\\cityMap\\XiAnCacheTiles\\xaMap\\Conf.xml</tilingScheme>
<tileCachePath>E:\\cityMap\\XiAnCacheTiles\\xaMap\\_alllayers\\</tileCachePath>
</arcgisLayer>
<arcgisLayer>
<name>china</name>
<tilingScheme>E:\\cityMap\\XiAnCacheTiles\\china\\Conf.xml</tilingScheme>
<tileCachePath>E:\\cityMap\\XiAnCacheTiles\\china\\_alllayers\\</tileCachePath>
</arcgisLayer>
二、gwc跨域问题解决
在geoserver中WEB-INF文件夹下,修改web.xml文件,添加过滤器内容,如下:
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
</init-param>
<init-param>
<param-name>cors.exposed.headers</param-name>
<param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
</init-param>
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>cors.preflight.maxage</param-name>
<param-value>10</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
修改完成保存,重新启动Tomcat即可跨域访问。