# qe-limit-height
这个组件主要用于三维中添加限高分析,支持动态高度渲染场景。模型限高分析是指在根据指定的分析区域、限定的高度将分析区域内的建筑物进行颜色区分,将超出限定高度部分的建筑物以红色覆盖,直观的表现超出限高建筑物。
# 实例
隐藏代码
<template>
<div class="container">
<div class="bar" style="position: absolute;top: 337px;right: 430px;">
<el-form label-width="70px">
<el-form-item label="分析区域">
<el-button type="primary" size="mini" @click="drawPolygon()">
绘制图形
</el-button>
<el-button type="danger" size="mini" @click="clear()">
清除
</el-button>
</el-form-item>
<span style="color:#fff;">限制高度</span>
<el-slider v-model="height" />
</el-form>
</div>
<qe-viewer
:imagery-type="'AMap'"
:default-view="defaultView"
:location-bar="false"
:viewer-mode="'3D'"
@ready="readyHandler"
>
<qe-primitive-layer :visible="true" :name="'倾斜摄影图层'">
<qe-tileset
v-for="(url, index) in testJson"
:key="index"
:url="url"
:is-zoom-to="true"
:tileset-options="tilesetOptions"
@ready="handleTileset"
/>
</qe-primitive-layer>
<qe-limit-height
v-if="limitvisible"
:positions="positions"
:base-height="baseHeight"
:height="height"
:color="color"
@ready="handlerLimit"
/>
</qe-viewer>
</div>
</template>
<script>
import { PrimitivePlot } from '@qycloud/qearth'
import { QeViewer,QeLimitHeight,QePrimitiveLayer,QeTileset } from '@qycloud/vue-qearth';
import 'vue2qearth/vue2qearth.css'
import ElementUI from 'element-ui'
import Vue from 'vue'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
export default {
components: {
QeViewer,
QeTileset,
QePrimitiveLayer,
QeLimitHeight
},
data() {
return {
limitvisible:true,
testJson: ['http://221.226.186.58:8025/qearth-tileset/tileset.json'],
defaultView: [122.06502636, 40.7235578, 1672, 357.62, -10.82, 359.99],
positions: [
[122.070346, 40.74897, 0],
[122.060904, 40.749976, 0],
[122.056038, 40.748859, 0],
[122.054289, 40.746575, 0],
[122.052546, 40.74403, 0],
[122.062438, 40.738918, 0],
[122.061701, 40.735537, 0],
[122.061014, 40.731852, 0],
[122.059006, 40.730159, 0],
[122.069271, 40.724039, 0],
[122.0791, 40.735799, 0],
[122.071142, 40.740778, 0]
],
baseHeight: 1, // 模型地面的海拔高度(单位:米)
height: 0, // 限高
color: 'rgba(255,0,0,0.5)',
tilesetOptions: {
maximumMemoryUsage: 32,
maximumScreenSpaceError: 16,
baseScreenSpaceError: 1024,
skipLevelOfDetail: true,
dynamicScreenSpaceError: true,
cullWithChildrenBounds: true,
cullRequestsWhileMoving: true,
preloadWhenHidden: true,
preloadFlightDestinations: true,
preferLeaves: true,
loadSiblings: false
}
}
},
watch: {
},
created() {
},
methods: {
readyHandler(e) {
window.viewer = e
window.plotInstance = new PrimitivePlot(window.viewer, {
usePrimitive: true,
useMeasure: false,
useContextMenu: true
})
window.plotInstance.on('drawEnd', e => {
this.positions = e?.data?.positions
window.plotInstance.clear()
this.limitvisible = true
})
window.plotInstance.on('change', e => {
this.positions = e?.data?.positions
window.plotInstance.clear()
})
},
handlerLimit(limit) {
this.limit = limit
},
handleTileset(tileset) {
tileset.setHeight(0)
},
clear() {
this.limitvisible = false
window.plotInstance&&window.plotInstance.terminate()
window.plotInstance && window.plotInstance.clear()
},
drawPolygon() {
this.limitvisible = false
window.plotInstance&&window.plotInstance.terminate()
window.plotInstance && window.plotInstance.clear()
window.plotInstance && window.plotInstance.draw('Polygon2D', {})
}
}
}
</script>
<style lang="scss" scoped>
.container {
height: 450px;
}
.bar {
padding: 20px 15px 0px 12px;
border: 2px solid #008aff70;
.el-form {
::v-deep .el-form-item__label {
color: #fff;
font-size: 14px;
}
::v-deep .el-input__inner {
height: 30px;
line-height: 30px;
width: 130px;
color: #fff;
border-radius: 2px;
background-color: transparent;
}
::v-deep .el-form-item {
margin-bottom: 10px;
}
}
position: absolute;
right: 20px;
top: 20px;
z-index: 2;
background-color: rgba(23, 49, 71, 0.8);
}
</style>
# Attributes
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
baseHeight | 模型地面的海拔高度(单位:米) | number | — | 0 |
height | 限制高度 | number | — | 0 |
color | 分析颜色 | string | — | rgba(255,0,0,0.5) |
alpha | 透明度 | number | — | — |
# Events
覆盖物事件的使用请参照上面LimitHeight 实例
// 覆盖物可选事件
"ready" // 组件装载后,返回当前实例对象