从后端调用栅格图层并显示在地图上

本文介绍了如何在JavaScript中使用GISAPI实现添加单个栅格图层的功能,包括`addRasterLayer`方法用于加载和添加图层,以及`clearLayer`方法用于清除当前图层。同时提到图层大小会自动适应并调整视图范围。
摘要由CSDN通过智能技术生成

实现样式

 /**
  * 添加单个栅格图层
  */
 addRasterLayer() {
     this.clearLayer()
     let proId = 'gep-r'
     let dataId = 'ecoSystemFile'
     let para = {
         'FORMAT': 'image/png',
         'VERSION': '1.1.1',
         "LAYERS": proId + ':' + dataId
     }
     this.currentLayer = new Image({
         source: new ImageWMS({
             ratio: 2,
             url: '/geo/' + proId + '/wms',
             params: para
         }),
     })
     this.map.addLayer(this.currentLayer)
     //设置图层大小自适应,extentRange:四至[minX,minY,maxX,maxY]
     this.map.getView().fit(this.extentRange, this.map.getSize())
 }

清空图层

 /**
  * 清空图层
  */
 clearLayer(){
     this.map.removeLayer(this.currentLayer)
     this.currentLayer = null
 }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值