OpenLayers和geowebcache结合

采用 geowebcache 缓存地图

1 .把 geowebcache 服务放到 tomcat 应用中,假设和 wms 服务放在同一个 tomcat 中,在 geowebcache/WEB-INF 下面找到 geowebcache-servlet.xml

在这个文件中有一段:

 <bean id="gwcWMSConfig" class="org.geowebcache.config.GetCapabilitiesConfiguration">
  	<constructor-arg ref="gwcGridSetBroker"/>
    <!-- The URL to the WMS GetCapabilities document -->
    <constructor-arg value="http://localhost:8000/wmsserver111/servlet/wms"/>
//替换成wms实际的url地址
。。。
  </bean>

 

2.在 geowebcache/WEB-INF/classes 中找到 geowebcache.xml 文件,打开文件,在 <layers> 标签中添加一个 <wmsLayer> ,如:

<wmsLayer>
    <name>gz</name>
    <metaInformation>
      <title>gz</title>
      <description>gz</description>
    </metaInformation>
     <mimeFormats><string>image/jpeg</string><string>image/gif</string><string>image/png</string></mimeFormats>
    <!-- Grid Subset Example -->
    <gridSubsets>
      <gridSubset>
        <gridSetName>EPSG:4326</gridSetName>
        <extent>
          <coords>
            <double>112.806</double>  
            <double>22.567</double>   
            <double>114.287</double>  
            <double>24.067</double>  
          </coords>
        </extent>
      </gridSubset>
    </gridSubsets>
    <wmsUrl>
      <string>http://localhost:8000/wmsserver111/servlet/wms</string>
    </wmsUrl>
<wmsLayers>layers/gz/xzqj,layers/gz/ld,layers/gz/sx,layers/gz/jmd,layers/gz/gsgl,layers/gz/gd,layers/gz/sd,layers/gz/ptgl,layers/gz/ybjd,layers/gz/cgd,layers/gz/zgd,layers/gz/zfjg</wmsLayers>
 //此处是mapxtreme480\resources\layers下面的命名资源
    <transparent>true</transparent>
    <bgColor></bgColor>
    <expireCacheList>
    	<expirationRule minZoom="10" expiration="600" />
    </expireCacheList>
    <expireClientsList>
     <expirationRule minZoom="0" expiration="7200" />
    </expireClientsList>
  </wmsLayer>

 

3 .编写 js 代码,其他代码不变修改如下:代码见:http://ninggy.iteye.com/blog/617150

  var tiled = new OpenLayers.Layer.WMS("背景图",
      "http://localhost:8000/geowebcache/service/wms?LAYERS=gz", {
        layers : 'gz',
        format : format
      }, {
        buffer : 0,
        displayOutsideMaxExtent : true,
        tileSize : new OpenLayers.Size(256, 256)
      });
 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值