arcgis js 动态绘制白膜

arcgis动态绘制白膜

export default {
  name: 'ControlHeight',
  data () {
    return {
      offsetHeight: 350,
      limitHeight: 100, // 限高高度
      opacity: 0,
      color: '#409EFF',
      currPolygon: null,
      polygonLayerList: [],
      polygonData: [],
      currChangedOpacity: 0,
      polygonNum: 0
    }
  },
  methods: {
    draw () {
      const self = this
      self.map.container.style.cursor = 'crosshair'
      let arr = []
      //   self.map.graphics.remove(self.currPolygon)
      const controlHeightGraphicLayer = new self.GraphicsLayer({
        // graphics: [graphic],
        elevationInfo: {
          mode: 'absolute-height',
          // 偏移
          offset: self.offsetHeight,
          unit: 'meters'
        }
        // screenSizePerspectiveEnabled: true
      })
      self.clickEvent = self.map.on('click', evt => {
        arr.push([evt.mapPoint.longitude, evt.mapPoint.latitude])
      })
      self.moveEvent = self.map.on('pointer-move', evt => {
        if (arr.length > 0) {
        //   self.map.graphics.remove(self.currPolygon)
          controlHeightGraphicLayer.graphics.remove(self.currPolygon)
          const mapPoint = self.map.toMap({ x: evt.x, y: evt.y })
          let arr2 = []
          arr.forEach(res => {
            arr2.push(res)
          })
          arr2.push([mapPoint.longitude, mapPoint.latitude])
          arr2.push(arr[0])

          const graphic = new self.Graphic({
            geometry: new self.Polygon({
            //   hasZ: true,
            //   hasM: false,
              rings: [arr2],
              spatialReference: self.map.spatialReference
            }),
            symbol: {
              type: 'polygon-3d', // 'simple-fill',
              symbolLayers: [{
                type: 'extrude',
                size: self.limitHeight,
                material: {
                  color: self.color
                  // opacity: (100 - self.opacity) / 100
                }
              }]
            //   color: [ 0, 255, 0, 0.2],
            //   style: 'solid',
            //   outline: {
            //     color: 'white',
            //     width: 1
            //   }
            }
          })
          controlHeightGraphicLayer.elevationInfo.offset = self.offsetHeight
          controlHeightGraphicLayer.opacity = (100 - self.opacity) / 100
          controlHeightGraphicLayer.graphics.add(graphic)
          //   self.map.graphics.add(graphic)
          self.map.map.add(controlHeightGraphicLayer)
          self.currPolygon = graphic
        }
      })
      self.dbclickEvent = self.map.on('double-click', evt => {
        evt.stopPropagation()
        self.map.container.style.cursor = 'default'
        self.clickEvent.remove()
        self.clickEvent = ''
        self.moveEvent.remove()
        self.moveEvent = ''
        self.dbclickEvent.remove()
        self.dbclickEvent = ''
        // console.log(self.currPolygon)
        // self.polygonLayerList.push(controlHeightGraphicLayer)
        self.polygonData.push({
          layer: controlHeightGraphicLayer,
          name: `模型_${self.polygonNum}`,
          opacity: self.opacity,
          edit: false
        })
        self.polygonNum++
        // self.geometry = self.polygonObj.geometry
      })
    },
    deleteGraphicer (row) {
      row.layer.removeAll()
      this.map.map.remove(row.layer)
      this.polygonData = this.polygonData.filter(item => item.layer !== row.layer)
    },
    editData (row) {
      row.edit = true
      this.currChangedOpacity = row.opacity
    },
    saveData (row) {
      row.layer.opacity = (100 - row.opacity) / 100
      row.edit = false
    },
    cancelSaveData (row) {
      row.layer.opacity = (100 - this.currChangedOpacity) / 100
      row.edit = false
    },
    changeOpacity (row) {
      row.layer.opacity = (100 - row.opacity) / 100
    },
    close () {
      this.polygonNum = 0
      this.$emit('close')
    }
  },
  mounted () {
    let self = this
    // self.wkid = sysConfig.wkid
    mapManager.getMap(this.mapId).then(({ map }) => {
      self.map = map
      esriLoader.loadModules([
        'esri/Map',
        'esri/layers/GraphicsLayer',
        'esri/widgets/Sketch/SketchViewModel',
        'esri/Graphic',
        'esri/geometry/Polygon'
      ], { url: serverConfig.arcgis_js_api_url }).then(([Map, GraphicsLayer, SketchViewModel, Graphic, Polygon]) => {
        self.Map = Map
        self.GraphicsLayer = GraphicsLayer
        self.SketchViewModel = SketchViewModel
        self.Graphic = Graphic
        self.Polygon = Polygon
      })
    })
  }
}

相关推荐

  1. arcgis js 动态绘制

    2024-04-13 09:20:02       113 阅读
  2. 绘制动态图表 Python

    2024-04-13 09:20:02       55 阅读
  3. cesiumlab切片通过arcgisjs加载

    2024-04-13 09:20:02       55 阅读
  4. 绘制一个动物——蟒蛇

    2024-04-13 09:20:02       61 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-13 09:20:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-13 09:20:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-13 09:20:02       87 阅读
  4. Python语言-面向对象

    2024-04-13 09:20:02       96 阅读

热门阅读

  1. halcon混合c#深度学习平整度怎么写

    2024-04-13 09:20:02       42 阅读
  2. Linux命令学习—linux 的硬件管理

    2024-04-13 09:20:02       35 阅读
  3. Python 装饰器

    2024-04-13 09:20:02       34 阅读
  4. 【QT教程】QT6_QML测试与调试技巧

    2024-04-13 09:20:02       31 阅读
  5. unicloud中文字段排序bug

    2024-04-13 09:20:02       137 阅读
  6. test4132

    test4132

    2024-04-13 09:20:02      37 阅读
  7. 二维数组得学习

    2024-04-13 09:20:02       134 阅读
  8. Scala详解(2)

    2024-04-13 09:20:02       77 阅读
  9. 数据库DMP格式备份文件

    2024-04-13 09:20:02       122 阅读