# qe-html-layer

html 图层组件,主要用于承载展示 html 元素,比如:qe-div-icon ...


# 实例

隐藏代码
<template>

  <div style="height: 450px;">
    <div  style="height: 8%;">
      <button @click="createMarkers" style="height: 30px;">
      点位测试
      </button>
    </div>
    <qe-viewer
      style="height: 90%;"
      :imagery-type="'AMap'"
      :fullscreen-button="true"
      :default-view="defaultView"
    >
      <qe-imagery-layer
        :imagery-provider-type="'arcgis'"
        :imagery-options="{
          url:
            'http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer'
        }"
      ></qe-imagery-layer>
      <qe-html-layer>
        <qe-div-icon 
          v-for="(item, index) in divIcons"
          :key="'div-icon' + index"
          :position="item.ps"
          :attr="item.attr"
          @click="markerEvents"
          >
          <div class="qe-animation-point" :style="{'color':item.color}">
            <p></p>
          </div>
        </qe-div-icon>
      </qe-html-layer>
    </qe-viewer>
  </div>
</template>

<script>
import { QeViewer, QeHtmlLayer, QeDivIcon,QeImageryLayer } from '@qycloud/vue-qearth';
import 'vue2qearth/vue2qearth.css'

export default {
  components: {
    QeViewer, 
    QeHtmlLayer, 
    QeDivIcon,
    QeImageryLayer
  },
  data () {
    return {
      divIcons:[],
      defaultView: [
        118.7863,
        31.9087,
        801.6425,
        1.724684714172732,
        -53.783141852231246,
        0.008819224020548466
      ],
      isShowLayer: true
    };
  },
  methods: {
    createMarkers() {
      for (let i = 0; i < 100; i++) {
        const ps = [
          Math.random() * 0.01 + 118.78600228,
          Math.random() * 0.01 + 31.9135434,
          0
        ];
        const color = this.createColor();
        this.divIcons.push({
          ps,
          color,
          attr: { ps, color }
        });
      }
    },
    createColor(){
			const r = Math.floor(Math.random()*256);
			const g = Math.floor(Math.random()*256);
			const b = Math.floor(Math.random()*256);
			const color = '#'+r.toString(16)+g.toString(16)+b.toString(16);
			return color;
		},
    markerEvents(evt) {
      const attr = evt.overlay.attr;
      alert(`当前点的颜色为--${attr.color}`)
    }
  }
}
</script>

# Attributes

参数 说明 类型 可选值 默认值
name 图层名称 string
id 图层唯一 id 不设置会自动生成 string
visible 图层是否可见 boolean true
minZoom 图层最小层级,低于最小层级则不显示 Number 0
maxZoom 图层最大层级,超过则不显示 Number 25
layerOptions 图层其他可选参数 object

# Events

覆盖物事件的使用请参照上面HtmlLayer 实例


// 图层可选事件
"ready" // 组件装载后,返回当前实例对象
最后更新时间: 8/16/2022, 10:45:53 AM