From 2411eb9a84f290fdb44852278c314df826ceb160 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Fri, 15 Apr 2022 13:56:47 +0800
Subject: [PATCH] 1
---
src/components/mobilemap/index.vue | 327 +++++++++++++++---------------------------------------
1 files changed, 91 insertions(+), 236 deletions(-)
diff --git a/src/components/mobilemap/index.vue b/src/components/mobilemap/index.vue
index c8e1ba6..abf278c 100644
--- a/src/components/mobilemap/index.vue
+++ b/src/components/mobilemap/index.vue
@@ -43,6 +43,7 @@
let baseLayer = []
let viewerHeight = 500
+let heightChange = 500
// baselayer
window.baselayer = null
@@ -69,7 +70,6 @@
data () {
return {
// 手动视图缩放控制
- startWheel: false,
heights: 0,
heights1: 0,
bigPopup: {
@@ -118,20 +118,20 @@
// mapCenter: [116.35381525 - 0.00035, 27.95839468 + 0.0025, 160.0],
// 控制4层缩放
// onelayerNum: 80,
- // towlayerNum: 120,
+ // twolayerNum: 120,
// threelayerNum: 160,
// fourlayerNum: null,
// intervallayerNum: 20,
// frislayertHeight: 120, // 默认高度
onelayerNum: 100,
- towlayerNum: 200,
+ twolayerNum: 200,
threelayerNum: 300,
fourlayerNum: 400,
-
fivelayerNum: 500,
+
sixlayerNum: null,
- intervallayerNum: 36,
+ intervallayerNum: 50,
frislayertHeight: 500, // 默认高度
useZoom: false, // 是否缩放 true 去掉了缩放, 抚州 false
addOthers: false // 加入了活动底图以及抚州底图 抚州 true
@@ -176,7 +176,7 @@
// 抚州视角数据
this.mapCenter = [116.35571525, 27.95839468 + 0.0067, 160.0]
this.onelayerNum = 100
- this.towlayerNum = 300
+ this.twolayerNum = 300
this.threelayerNum = 500
this.fourlayerNum = 700
this.fivelayerNum = null
@@ -887,10 +887,6 @@
that.mapMouseMove()
}
global.DC.ready(window.initViewer)
-
- this.$nextTick(() => {
- this.controlButton()
- })
},
methods: {
getViewExtend () {
@@ -987,166 +983,85 @@
updateBaseLayer (flag) {
const extent = this.getViewExtend()
- baseLayerImgUrl.forEach(item => {
- if (item[viewerHeight]) {
- item[viewerHeight].forEach(sm => {
- let startFlag = true
- if (flag == true) {
- baseLayer.forEach(dt => {
- if (dt.id == sm.id) startFlag = false
- })
- }
+ const array = baseLayerImgUrl.filter(item => {
+ return item[viewerHeight]
+ })
- if (startFlag == false) return
-
- if (
- (
- sm.rectangle[0] > extent.minx &&
- sm.rectangle[1] > extent.miny &&
- sm.rectangle[2] < extent.maxx &&
- sm.rectangle[3] < extent.maxy
- ) ||
- (
- sm.rectangle[0] < extent.minx &&
- sm.rectangle[1] < extent.maxy &&
- sm.rectangle[2] > extent.minx &&
- sm.rectangle[3] > extent.maxy
- ) ||
- (
- sm.rectangle[0] < extent.maxx &&
- sm.rectangle[1] < extent.maxy &&
- sm.rectangle[2] > extent.maxx &&
- sm.rectangle[3] > extent.maxy
- ) ||
- (
- sm.rectangle[0] < extent.maxx &&
- sm.rectangle[1] < extent.miny &&
- sm.rectangle[2] > extent.maxx &&
- sm.rectangle[3] > extent.miny
- ) ||
- (
- sm.rectangle[0] < extent.minx &&
- sm.rectangle[1] < extent.miny &&
- sm.rectangle[2] > extent.minx &&
- sm.rectangle[3] > extent.miny
- ) ||
- (
- sm.rectangle[0] > extent.minx &&
- sm.rectangle[1] < extent.maxy &&
- sm.rectangle[2] < extent.maxx &&
- sm.rectangle[3] > extent.maxy
- ) ||
- (
- sm.rectangle[0] > extent.minx &&
- sm.rectangle[1] > extent.miny &&
- sm.rectangle[2] > extent.maxx &&
- sm.rectangle[3] < extent.maxy
- ) ||
- (
- sm.rectangle[0] > extent.minx &&
- sm.rectangle[1] < extent.miny &&
- sm.rectangle[2] < extent.maxx &&
- sm.rectangle[3] > extent.miny
- ) ||
- (
- sm.rectangle[0] < extent.minx &&
- sm.rectangle[1] > extent.miny &&
- sm.rectangle[2] > extent.minx &&
- sm.rectangle[3] < extent.maxy
- )
- ) {
- var layer = global.viewer.imageryLayers.addImageryProvider(new global.DC.Namespace.Cesium.SingleTileImageryProvider({
- url: sm.url,
- rectangle: global.DC.Namespace.Cesium.Rectangle.fromDegrees(sm.rectangle[0], sm.rectangle[1], sm.rectangle[2], sm.rectangle[3])
- }))
-
- baseLayer.push({ layer, id: sm.id })
- }
+ array[0][viewerHeight].forEach(sm => {
+ let startFlag = false
+ if (flag == true) {
+ startFlag = baseLayer.some(dt => {
+ return dt.id == sm.id
})
}
- })
- },
- // 按钮控制视图改变得事件
- controlButton () {
- const that = this
- document.querySelector('.dc-zoom-controller').children[0].onclick =
- function () {
- if (that.useZoom) {
- return
- }
- if (that.dimension == '2.5D') {
- if (viewerHeight == that.fivelayerNum) {
- that.butSetViews(that.fourlayerNum)
- return
- }
+ if (startFlag == true) return
- if (viewerHeight == that.fourlayerNum) {
- that.butSetViews(that.threelayerNum)
- return
- }
+ if (
+ (
+ sm.rectangle[0] > extent.minx &&
+ sm.rectangle[1] > extent.miny &&
+ sm.rectangle[2] < extent.maxx &&
+ sm.rectangle[3] < extent.maxy
+ ) ||
+ (
+ sm.rectangle[0] < extent.minx &&
+ sm.rectangle[1] < extent.maxy &&
+ sm.rectangle[2] > extent.minx &&
+ sm.rectangle[3] > extent.maxy
+ ) ||
+ (
+ sm.rectangle[0] < extent.maxx &&
+ sm.rectangle[1] < extent.maxy &&
+ sm.rectangle[2] > extent.maxx &&
+ sm.rectangle[3] > extent.maxy
+ ) ||
+ (
+ sm.rectangle[0] < extent.maxx &&
+ sm.rectangle[1] < extent.miny &&
+ sm.rectangle[2] > extent.maxx &&
+ sm.rectangle[3] > extent.miny
+ ) ||
+ (
+ sm.rectangle[0] < extent.minx &&
+ sm.rectangle[1] < extent.miny &&
+ sm.rectangle[2] > extent.minx &&
+ sm.rectangle[3] > extent.miny
+ ) ||
+ (
+ sm.rectangle[0] > extent.minx &&
+ sm.rectangle[1] < extent.maxy &&
+ sm.rectangle[2] < extent.maxx &&
+ sm.rectangle[3] > extent.maxy
+ ) ||
+ (
+ sm.rectangle[0] > extent.minx &&
+ sm.rectangle[1] > extent.miny &&
+ sm.rectangle[2] > extent.maxx &&
+ sm.rectangle[3] < extent.maxy
+ ) ||
+ (
+ sm.rectangle[0] > extent.minx &&
+ sm.rectangle[1] < extent.miny &&
+ sm.rectangle[2] < extent.maxx &&
+ sm.rectangle[3] > extent.miny
+ ) ||
+ (
+ sm.rectangle[0] < extent.minx &&
+ sm.rectangle[1] > extent.miny &&
+ sm.rectangle[2] > extent.minx &&
+ sm.rectangle[3] < extent.maxy
+ )
+ ) {
+ var layer = global.viewer.imageryLayers.addImageryProvider(new global.DC.Namespace.Cesium.SingleTileImageryProvider({
+ url: sm.url,
+ rectangle: global.DC.Namespace.Cesium.Rectangle.fromDegrees(sm.rectangle[0], sm.rectangle[1], sm.rectangle[2], sm.rectangle[3])
+ }))
- if (viewerHeight == that.threelayerNum) {
- that.butSetViews(that.towlayerNum)
- return
- }
-
- if (viewerHeight == that.towlayerNum) {
- that.butSetViews(that.onelayerNum)
- }
- }
- }
-
- // 缩小
- document.querySelector('.dc-zoom-controller').children[2].onclick =
- function () {
- if (that.useZoom) {
- return
- }
- if (that.dimension == '2.5D') {
- if (viewerHeight == that.onelayerNum) {
- that.butSetViews(that.towlayerNum)
- return
- }
-
- if (viewerHeight == that.towlayerNum) {
- that.butSetViews(that.threelayerNum)
- return
- }
-
- if (viewerHeight == that.threelayerNum) {
- that.butSetViews(that.fourlayerNum)
- return
- }
-
- if (viewerHeight == that.fourlayerNum) {
- that.butSetViews(that.fivelayerNum)
- }
- }
- }
- },
-
- // 位置更改并且重新加载视图
- butSetViews (num) {
- viewerHeight = num
-
- global.viewer.camera.setView({
- destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
- global.viewer.camera.positionCartographic.longitude,
- global.viewer.camera.positionCartographic.latitude,
- num
- ),
- orientation: {
- // 指向
- heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
- // 视角
- pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
- roll: 0.0
+ baseLayer.push({ layer, id: sm.id })
}
})
-
- this.addBaseLayer()
},
// 手动控制地图缩放得
@@ -1158,88 +1073,28 @@
return
}
+ heightChange = viewerHeight
+
if (that.dimension == '2.5D') {
var height = global.viewer.camera.positionCartographic.height
- if (that.startWheel == true) {
- if (height < viewerHeight - that.intervallayerNum) {
- if (viewerHeight == that.fivelayerNum) {
- that.butSetViews(that.fourlayerNum)
- that.startWheel = false
- return
- }
+ if (height > that.fivelayerNum - that.intervallayerNum) {
+ viewerHeight = that.fivelayerNum
+ } else if (height <= that.fourlayerNum + that.intervallayerNum && height > that.fourlayerNum - that.intervallayerNum) {
+ viewerHeight = that.fourlayerNum
+ } else if (height <= that.fourlayerNum + that.intervallayerNum && height > that.threelayerNum - that.intervallayerNum) {
+ viewerHeight = that.threelayerNum
+ } else if (height <= that.twolayerNum + that.intervallayerNum && height > that.twolayerNum - that.intervallayerNum) {
+ viewerHeight = that.twolayerNum
+ } else if (height <= that.onelayerNum + that.intervallayerNum) {
+ viewerHeight = that.onelayerNum
+ }
- if (viewerHeight == that.fourlayerNum) {
- that.butSetViews(that.threelayerNum)
-
- that.startWheel = false
- return
- }
-
- if (viewerHeight == that.threelayerNum) {
- that.butSetViews(that.towlayerNum)
-
- that.startWheel = false
- return
- }
-
- if (viewerHeight == that.towlayerNum) {
- that.butSetViews(that.onelayerNum)
-
- that.startWheel = false
- }
- } else if (height > viewerHeight + that.intervallayerNum) {
- if (viewerHeight == that.onelayerNum) {
- that.butSetViews(that.towlayerNum)
-
- that.startWheel = false
- return
- }
-
- if (viewerHeight == that.towlayerNum) {
- that.butSetViews(that.threelayerNum)
-
- that.startWheel = false
- return
- }
-
- if (viewerHeight == that.threelayerNum) {
- that.butSetViews(that.fourlayerNum)
-
- that.startWheel = false
- return
- }
-
- if (viewerHeight == that.fourlayerNum) {
- that.butSetViews(that.fivelayerNum)
-
- that.startWheel = false
- }
- } else {
- global.viewer.camera.setView({
- destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
- global.viewer.camera.positionCartographic.longitude,
- global.viewer.camera.positionCartographic.latitude,
- viewerHeight
- ),
- orientation: {
- // 指向
- heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
- // 视角
- pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
- roll: 0.0
- }
- })
-
- that.startWheel = false
- }
+ if (heightChange != viewerHeight) {
+ that.addBaseLayer()
}
that.updateBaseLayer(true)
-
- setTimeout(() => {
- that.startWheel = true
- }, 100)
}
})
}
--
Gitblit v1.9.3