积累-gis相关

一、maptalks

1、定位

  /**
   * 定位
   */
  centerTOPoint = ( longitude , latitude ) => {
    const coord = new Coordinate(longitude , latitude)
    if (this.map.getZoom() >= 15) {
      this.map.panTo(coord, {
        animation : true,
        duration : 1000 // 默认值为600
      })
    } else {
      this.map.setCenter(coord)
      this.map.setZoom(15)
    }
  }

2 、map事件使用

    this.map.on('click', (param)  => {
      console.log('handle')
    })

3、移除指定id的图层

  /**
   * 移除指定id的图层
   * @param {*} key
   */
deleteLayer (key) {
    console.log('移除id=' + key + '的图层')
    const layer = this.map.getLayer(key)
    this.map.remove(layer)
  }

4、指定id的图层的显隐控制

 /**
   * 切换指定图层的显示隐藏
   */
  toggleReaultLayer = (key , checked) => {
    const layer = this.map.getLayer(key)
    if (checked === false) {
      layer.hide()
      console.log('隐藏id=' + key + '的图层')
    } else {
      ayer.show()
      console.log('显示id=' + key + '的图层')
    }
  }

maptalks测量清除方法

 /**
   * 清除所有地图常用小工具留在地图上的标记
   */
  clear = () => {
  // 结束距离测量和面积测量的绘制防止出现标记已清除但还可以绘制的bug
    this.distanceTool.endDraw()
    this.areaTool.endDraw()
    
    this.distanceTool.clear() // 清除距离测量结果
    this.areaTool.clear() // 清除面积测量结果
  }

map事件使用

猜你喜欢

转载自blog.csdn.net/m0_37148591/article/details/82900551
GIS