vue 项目 openlayer 加载 WMS 图层

这篇博文详细介绍了如何在Vue项目中利用OpenLayers库加载GeoServer发布的WMS图层。首先,展示了GeoServer发布的WMS图层链接,接着讲解了OpenLayers中设置投影、分辨率、矩阵集等关键参数的过程,并提供了具体的代码示例,最终成功将WMTS图层添加到地图中。
摘要由CSDN通过智能技术生成

vue 项目 openlayer 加载 WMS 图层

这个是啥子情况呢,是我用 openlayer 加载 geoserve 发布的图层,然后发布出来的图层是 wms 的,所以说这篇博文主要是用来操作 vue 项目使用 openlayers 加载 geoserve 发布的 wms 图层。

geoserve 发布的图层地址

在这里插入图片描述
上面的就是 geoserve 发不出来的 WMS 图层连接。

openlayer 加载 WMS 图层

具体我不知道为啥这样写哈,但是我这样设置是可以加载出来的啊!

const projection = olProj.get('EPSG:900913');
        const projectionExtent = projection.getExtent();
        const size = olExtent.getWidth(projectionExtent) / 256;
        const resolutions = new Array(19);
        const matrixIds = new Array(19);
        for (let z = 0; z < 19; ++z) {
          resolutions[z] = size / Math.pow(2, z);
          matrixIds[z] = "EPSG:900913:" + z;
        }
        const layerName = 'map:china_all'  // 提换成自己的
        let wmtsSource = new WMTS({
          url: 'http://127.0.0.1:8080/geoserver/gwc/service/wmts',  // 替换成自己服务器的
          layer: layerName,
          matrixSet: 'EPSG:900913',
          format: 'image/png',
          projection: projection,
          tileGrid: new WMTSTileGrid({
            origin: olExtent.getTopLeft(projectionExtent),
            resolutions: resolutions,
            matrixIds: matrixIds,
          }),
          style: '',
          wrapX: true,
        });
        let wmtsService = new TileLayer({
          source: wmtsSource,
          zIndex: 0,
        });
        this.mapLayers = [wmtsService]
        map.addLayer(wmtsService)

然后就可以了。

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值