From 81f54040c2cb65537c6c6e1db8358a39a57dea0d Mon Sep 17 00:00:00 2001
From: mayisheng <admin>
Date: Mon, 15 Aug 2022 16:14:01 +0800
Subject: [PATCH] 1
---
src/mobileDivForms/mobileDivForms.js | 82 +++++++++++++++++++++++++++++------------
1 files changed, 58 insertions(+), 24 deletions(-)
diff --git a/src/mobileDivForms/mobileDivForms.js b/src/mobileDivForms/mobileDivForms.js
index 3aa512a..1c6d774 100644
--- a/src/mobileDivForms/mobileDivForms.js
+++ b/src/mobileDivForms/mobileDivForms.js
@@ -10,8 +10,6 @@
import DC from '@dvgis/dc-sdk/dist/dc.base.min' // 基础包
import DcCore from '@dvgis/dc-sdk/dist/dc.core.min' // 核心包
-var $ = window.$
-
DC.use(DcCore) // 安装DC核心库
class mobileDivForms {
@@ -26,29 +24,30 @@
this._title = popup.title
this._content = popup.content
this.appendPopup()
+ this.isOpen = true
}
- get viewer() {
+ get viewer () {
return this._viewer
}
- get title() {
+ get title () {
return this._title
}
- get content() {
+ get content () {
return this._content
}
- get popup() {
+ get popup () {
return this._popup
}
- get position() {
+ get position () {
return this._position
}
- appendPopup() {
+ appendPopup () {
/**
* @domId 存放 dom 的id, 多个数组,单个字符串
*/
@@ -57,7 +56,10 @@
}
// 创建元素并追加
- createVideoWindowAll(id, className, position) {
+ createVideoWindowAll (id, className, position) {
+ const dom = document.getElementById('mobile-map_popup_content')
+ dom.style.display = 'block'
+
var childs = document.getElementById('mobile-map_popup_content').getElementsByTagName('div')
if (childs.length > 0) {
@@ -68,37 +70,56 @@
var self = this
- var el = $("<div class=''></div>")
+ // var el = $("<div class=''></div>")
- var titleDiv = $("<div class='mobiletitle'></div>").text(this._title)
- var labelContent = $("<div class='mobilelabel-content'></div>").append(this._content)
+ var el = document.createElement('div')
- el.append(titleDiv)
- el.append(labelContent)
+ // var titleDiv = $("<div class='mobiletitle'></div>").text(this._title)
+ // var labelContent = $("<div class='mobilelabel-content'></div>").append(this._content)
- el.attr('id', id)
+ // el.append(titleDiv)
+ // el.append(labelContent)
+ el.appendChild(this._content)
- el.addClass(className || '')
+ el.setAttribute('id', id)
- $('#mobile-map_popup_content').append(el)
+ el.setAttribute('class', className || '')
- this._viewer.scene.postRender.addEventListener(function () {
+ document.getElementById('mobile-map_popup_content').appendChild(el)
+ // let time;
+ // function cons(e) {
+ // time = setTimeout(() => {
+ // console.log(e)
+ // console.log(e.sun._drawingBufferHeight)
+ // console.log("roll: ", e.camera.roll)
+ // console.log("pitch: ", e.camera.pitch)
+ // console.log("heading: ", e.camera.heading)
+ // clearTimeout(time);
+ // time = "";
+ // }, 2000);
+ // }
+
+ this._viewer.scene.postRender.addEventListener(function (e) {
+ if (!self.isOpen) {
+ return
+ }
const windowCoord = DC.Namespace.Cesium.SceneTransforms.wgs84ToWindowCoordinates(
self._viewer.scene,
position
)
-
+ // time || cons(e);
self.positionPopUp(windowCoord, id)
})
}
- positionPopUp(windowCoord, id) {
+ positionPopUp (windowCoord, id) {
if (!windowCoord) {
- return;
+ return
}
- const wx = document.getElementById('app').clientWidth;
- const x = windowCoord.x - (wx / 100 * 35);
- const y = windowCoord.y - document.getElementById(id).offsetHeight - 15;
+ // console.log(windowCoord)
+ const wx = document.getElementById('app').clientWidth
+ const x = windowCoord.x - (wx / 100 * 35)
+ const y = windowCoord.y - document.getElementById(id).offsetHeight - 15
// x = windowCoord.x - document.getElementById(id).offsetWidth
// document.getElementById(id).style.cssText = `
@@ -108,6 +129,19 @@
transform:translate3d(${Math.round(x)}px,${Math.round(y)}px, 0);
`
}
+
+ closeOur () {
+ this.isOpen = false
+ const dom = document.getElementById('mobile-map_popup_content')
+ dom.style.display = 'none'
+ // var childs = document.getElementById('mobile-map_popup_content').getElementsByTagName('div')
+
+ // if (childs.length > 0) {
+ // for (var i = 0; i < childs.length; i++) {
+ // document.getElementById('mobile-map_popup_content').removeChild(childs[i])
+ // }
+ // }
+ }
}
export default mobileDivForms
--
Gitblit v1.9.3