更新
This commit is contained in:
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
17
public/index.html
Normal file
17
public/index.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
</body>
|
||||
</html>
|
||||
BIN
public/zhenggui.png
Normal file
BIN
public/zhenggui.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.4 MiB |
88
src/App.vue
Normal file
88
src/App.vue
Normal file
@@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<!-- 导航栏 -->
|
||||
<nav class="app-nav" v-if="currentPage !== 'campusMap'">
|
||||
<button @click="goToCampusMap" class="nav-btn">
|
||||
← 返回园区地图
|
||||
</button>
|
||||
<h1>建筑平面图</h1>
|
||||
</nav>
|
||||
|
||||
<!-- 页面内容 -->
|
||||
<CampusMap v-if="currentPage === 'campusMap'" @navigate="handleNavigation" />
|
||||
<HelloWorld v-else />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from 'vue'
|
||||
import HelloWorld from './components/HelloWorld.vue'
|
||||
import CampusMap from './components/CampusMap.vue'
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
components: {
|
||||
HelloWorld,
|
||||
CampusMap
|
||||
},
|
||||
setup() {
|
||||
const currentPage = ref('campusMap') // 默认显示园区地图
|
||||
|
||||
const handleNavigation = (page) => {
|
||||
currentPage.value = page
|
||||
}
|
||||
|
||||
const goToCampusMap = () => {
|
||||
currentPage.value = 'campusMap'
|
||||
}
|
||||
|
||||
return {
|
||||
currentPage,
|
||||
handleNavigation,
|
||||
goToCampusMap
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#app {
|
||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
color: #2c3e50;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.app-nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 15px 20px;
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
border-bottom: 1px solid #e8e8e8;
|
||||
}
|
||||
|
||||
.nav-btn {
|
||||
padding: 8px 16px;
|
||||
background: #1890ff;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
|
||||
.nav-btn:hover {
|
||||
background: #40a9ff;
|
||||
}
|
||||
|
||||
.app-nav h1 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
BIN
src/assets/logo.png
Normal file
BIN
src/assets/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
277
src/components/CampusMap.vue
Normal file
277
src/components/CampusMap.vue
Normal file
@@ -0,0 +1,277 @@
|
||||
<template>
|
||||
<div class="campus-map-container">
|
||||
<div ref="mapContainer" class="campus-map"></div>
|
||||
<div class="map-controls">
|
||||
<button @click="goToBuildingDetail" class="control-btn">进入建筑详情</button>
|
||||
<button @click="resetView" class="control-btn">重置视图</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import L from 'leaflet'
|
||||
import 'leaflet/dist/leaflet.css'
|
||||
|
||||
export default {
|
||||
name: 'CampusMap',
|
||||
emits: ['navigate'],
|
||||
data() {
|
||||
return {
|
||||
map: null,
|
||||
mapConfig: {
|
||||
// 园区地图的边界坐标(使用更合理的默认尺寸)
|
||||
imageWidth: 1200, // 假设图片宽度
|
||||
imageHeight: 800, // 假设图片高度
|
||||
// 标点位置(使用相对位置,更容易看到)
|
||||
markers: [
|
||||
{ id: 'building1', position: [530, 280], name: '建筑A', target: 'helloWorld' },
|
||||
{ id: 'building2', position: [800, 500], name: '建筑B', target: 'helloWorld' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initMap()
|
||||
},
|
||||
beforeUnmount() {
|
||||
if (this.map) {
|
||||
this.map.remove()
|
||||
this.map = null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initMap() {
|
||||
if (!this.$refs.mapContainer) return
|
||||
|
||||
// 创建地图实例
|
||||
this.map = L.map(this.$refs.mapContainer, {
|
||||
crs: L.CRS.Simple, // 使用简单坐标系
|
||||
minZoom: -2,
|
||||
maxZoom: 4
|
||||
})
|
||||
|
||||
// 使用配置的图片尺寸
|
||||
const imageWidth = this.mapConfig.imageWidth
|
||||
const imageHeight = this.mapConfig.imageHeight
|
||||
|
||||
// 设置地图边界
|
||||
const southWest = this.map.unproject([0, imageHeight], this.map.getMaxZoom())
|
||||
const northEast = this.map.unproject([imageWidth, 0], this.map.getMaxZoom())
|
||||
const bounds = new L.LatLngBounds(southWest, northEast)
|
||||
|
||||
// 添加图片作为底图
|
||||
L.imageOverlay('/zhenggui.png', bounds).addTo(this.map)
|
||||
|
||||
// 设置地图视图到整个图片范围
|
||||
this.map.fitBounds(bounds)
|
||||
|
||||
// 添加标点
|
||||
this.addMarkers()
|
||||
|
||||
// 添加缩放控件
|
||||
L.control.zoom({
|
||||
position: 'topright'
|
||||
}).addTo(this.map)
|
||||
|
||||
},
|
||||
|
||||
addMarkers() {
|
||||
this.mapConfig.markers.forEach(markerConfig => {
|
||||
// 将自定义坐标转换为地图坐标
|
||||
const mapPoint = this.map.unproject(markerConfig.position, this.map.getMaxZoom())
|
||||
|
||||
// 创建更醒目的自定义图标
|
||||
const customIcon = L.divIcon({
|
||||
html: `
|
||||
<div class="custom-marker" style="cursor: pointer;">
|
||||
<div class="marker-pin" style="background: #ff4444; border: 3px solid white; width: 40px; height: 40px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 0 10px rgba(255, 0, 0, 0.8);"></div>
|
||||
<div class="marker-label" style="position: absolute; top: -35px; left: 50%; transform: translateX(-50%); background: #ff4444; color: white; padding: 4px 12px; border-radius: 20px; font-size: 14px; font-weight: bold; white-space: nowrap; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); border: 2px solid white;">${markerConfig.name}</div>
|
||||
</div>
|
||||
`,
|
||||
className: 'custom-div-icon',
|
||||
iconSize: [40, 50],
|
||||
iconAnchor: [20, 50]
|
||||
})
|
||||
|
||||
// 添加标记
|
||||
const marker = L.marker(mapPoint, { icon: customIcon }).addTo(this.map)
|
||||
|
||||
// 添加调试信息
|
||||
console.log(`添加标记: ${markerConfig.name},位置:`, markerConfig.position)
|
||||
|
||||
// 添加点击事件
|
||||
marker.on('click', () => {
|
||||
this.handleMarkerClick(markerConfig)
|
||||
})
|
||||
|
||||
// 添加悬停效果(使用不改变位置的样式)
|
||||
marker.on('mouseover', () => {
|
||||
const element = marker.getElement()
|
||||
if (element) {
|
||||
const pin = element.querySelector('.marker-pin')
|
||||
const label = element.querySelector('.marker-label')
|
||||
if (pin) {
|
||||
pin.style.background = '#ff0000'
|
||||
pin.style.boxShadow = '0 0 15px rgba(255, 0, 0, 1)'
|
||||
pin.style.transform = 'rotate(-45deg) scale(1.1)'
|
||||
}
|
||||
if (label) {
|
||||
label.style.background = '#ff0000'
|
||||
label.style.boxShadow = '0 4px 12px rgba(255, 0, 0, 0.6)'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
marker.on('mouseout', () => {
|
||||
const element = marker.getElement()
|
||||
if (element) {
|
||||
const pin = element.querySelector('.marker-pin')
|
||||
const label = element.querySelector('.marker-label')
|
||||
if (pin) {
|
||||
pin.style.background = '#ff4444'
|
||||
pin.style.boxShadow = '0 0 10px rgba(255, 0, 0, 0.8)'
|
||||
pin.style.transform = 'rotate(-45deg) scale(1)'
|
||||
}
|
||||
if (label) {
|
||||
label.style.background = '#ff4444'
|
||||
label.style.boxShadow = '0 2px 8px rgba(0, 0, 0, 0.3)'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
handleMarkerClick(markerConfig) {
|
||||
console.log(`点击了标记: ${markerConfig.name}`)
|
||||
|
||||
// 根据标记配置跳转到对应页面
|
||||
if (markerConfig.target === 'helloWorld') {
|
||||
this.$emit('navigate', 'helloWorld')
|
||||
}
|
||||
},
|
||||
|
||||
goToBuildingDetail() {
|
||||
// 触发导航事件,跳转到HelloWorld页面(平面图)
|
||||
this.$emit('navigate', 'helloWorld')
|
||||
},
|
||||
|
||||
resetView() {
|
||||
if (this.map) {
|
||||
// 重新计算边界并重置视图
|
||||
const imageWidth = 2000
|
||||
const imageHeight = 1500
|
||||
const southWest = this.map.unproject([0, imageHeight], this.map.getMaxZoom())
|
||||
const northEast = this.map.unproject([imageWidth, 0], this.map.getMaxZoom())
|
||||
const bounds = new L.LatLngBounds(southWest, northEast)
|
||||
this.map.fitBounds(bounds)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.campus-map-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.campus-map {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.map-controls {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.control-btn {
|
||||
padding: 10px 16px;
|
||||
background: #fff;
|
||||
border: 2px solid #1890ff;
|
||||
border-radius: 6px;
|
||||
color: #1890ff;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.control-btn:hover {
|
||||
background: #1890ff;
|
||||
color: #fff;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(24, 144, 255, 0.4);
|
||||
}
|
||||
|
||||
.control-btn:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
/* 自定义标记样式 */
|
||||
.custom-marker {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.marker-pin {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
background: #ff6b6b;
|
||||
border: 3px solid #fff;
|
||||
border-radius: 50% 50% 50% 0;
|
||||
transform: rotate(-45deg);
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.marker-label {
|
||||
position: absolute;
|
||||
top: -25px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: #fff;
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.marker-hover .marker-pin {
|
||||
background: #ff5252;
|
||||
transform: rotate(-45deg) scale(1.1);
|
||||
}
|
||||
|
||||
.marker-hover .marker-label {
|
||||
background: #1890ff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Leaflet 样式调整 */
|
||||
:deep(.leaflet-control-zoom) {
|
||||
border: none;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
:deep(.leaflet-control-zoom a) {
|
||||
background: #fff;
|
||||
border: none;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
:deep(.leaflet-control-zoom a:hover) {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
</style>
|
||||
624
src/components/HelloWorld.vue
Normal file
624
src/components/HelloWorld.vue
Normal file
@@ -0,0 +1,624 @@
|
||||
<template>
|
||||
<div class="map-container">
|
||||
<div ref="mapContainer" class="map"></div>
|
||||
|
||||
<!-- 摄像头监控弹窗 -->
|
||||
<div v-if="showPopup && currentPopupType === 'camera'" class="camera-popup" :style="{ top: popupPosition.y + 'px', left: popupPosition.x + 'px' }">
|
||||
<div class="popup-header">
|
||||
<h3>{{ currentCamera.name }}</h3>
|
||||
<div class="camera-status">
|
||||
<span class="status-dot" :class="{ online: currentCamera.status === 'online' }"></span>
|
||||
<span class="status-text">{{ currentCamera.status === 'online' ? '在线' : '离线' }}</span>
|
||||
</div>
|
||||
<button @click="closePopup" class="close-btn">×</button>
|
||||
</div>
|
||||
<div class="popup-content">
|
||||
<div class="video-container">
|
||||
<video
|
||||
v-if="currentCamera.status === 'online'"
|
||||
ref="cameraVideo"
|
||||
:src="currentCamera.streamUrl"
|
||||
autoplay
|
||||
muted
|
||||
controls
|
||||
class="camera-video"
|
||||
@error="handleVideoError"
|
||||
>
|
||||
您的浏览器不支持视频播放
|
||||
</video>
|
||||
<div v-else class="offline-placeholder">
|
||||
<div class="offline-icon">📹</div>
|
||||
<p>摄像头离线</p>
|
||||
</div>
|
||||
</div>
|
||||
<!--
|
||||
<div class="camera-controls">
|
||||
<button @click="toggleCameraFullscreen" class="control-btn">
|
||||
{{ isCameraFullscreen ? '退出全屏' : '全屏' }}
|
||||
</button>
|
||||
<button @click="takeScreenshot" class="control-btn">截图</button>
|
||||
<button @click="toggleCameraAudio" class="control-btn">
|
||||
{{ isAudioMuted ? '开启声音' : '静音' }}
|
||||
</button>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
|
||||
const mapContainer = ref(null)
|
||||
let map = null
|
||||
let floorsComp = null
|
||||
|
||||
// 从2.html中提取的配置参数
|
||||
const mapConfig = {
|
||||
verifyUrl: 'https://www.ooomap.com/ooomap-verify/check/50689bb01e0ac2a9d93bb18f1e1260f8',
|
||||
appID: '87ae6a00e5ca4e33dd7e858a66b73475'
|
||||
}
|
||||
|
||||
const initMap = () => {
|
||||
if (!mapContainer.value) return
|
||||
|
||||
// 检查ooomap是否已加载
|
||||
if (typeof window.om === 'undefined') {
|
||||
console.error('ooomap SDK未加载,请检查引入是否正确')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// 初始化ooomap实例 - 使用2.html中的配置
|
||||
map = new window.om.Map({
|
||||
container: mapContainer.value,
|
||||
verifyUrl: mapConfig.verifyUrl,
|
||||
appID: mapConfig.appID
|
||||
})
|
||||
|
||||
// 当建筑数据加载完成时, 将建筑的室外模型数据合入
|
||||
map.on('buildingDataLoaded-pre', bd => {
|
||||
// 注意:这里需要根据实际项目结构调整模型路径
|
||||
// load local glb models
|
||||
window.om.ajax({
|
||||
url: './models/hospital/modelsData.json',
|
||||
success: function (res) {
|
||||
bd.models = res.models
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// 加入楼层组件
|
||||
if (typeof window.Comp_floors !== 'undefined') {
|
||||
floorsComp = new window.Comp_floors({
|
||||
target: mapContainer.value,
|
||||
props: {
|
||||
hasOutdoor: true,
|
||||
style: 'right: 10px;bottom: 80px;'
|
||||
}
|
||||
})
|
||||
floorsComp.bind(map)
|
||||
}
|
||||
|
||||
// 窗口大小变化时调整地图视图
|
||||
window.addEventListener('resize', handleResize)
|
||||
|
||||
// 地图加载完成回调
|
||||
map.on('load', () => {
|
||||
console.log('ooomap加载完成')
|
||||
})
|
||||
|
||||
// 错误处理
|
||||
map.on('error', (error) => {
|
||||
console.error('ooomap加载错误:', error)
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
console.error('初始化ooomap失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const handleResize = () => {
|
||||
if (map && map.view) {
|
||||
map.view.resize()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
// 动态加载ooomap SDK和相关组件
|
||||
const scripts = [
|
||||
'https://www.ooomap.com/sdk/dev/ooomap.min.js',
|
||||
'https://www.ooomap.com/sdk/comps/comp_floors/comp_floors.js'
|
||||
]
|
||||
|
||||
let loadedCount = 0
|
||||
|
||||
scripts.forEach(src => {
|
||||
const script = document.createElement('script')
|
||||
script.src = src
|
||||
script.onload = () => {
|
||||
loadedCount++
|
||||
if (loadedCount === scripts.length) {
|
||||
console.log('所有ooomap SDK加载完成')
|
||||
initMap()
|
||||
// 地图加载完成后添加标注点
|
||||
addAnnotationsToMap()
|
||||
// 添加地图点击事件监听
|
||||
mapContainer.value.addEventListener('click', handleMapClick)
|
||||
}
|
||||
}
|
||||
script.onerror = () => {
|
||||
console.error(`ooomap SDK加载失败: ${src}`)
|
||||
}
|
||||
document.head.appendChild(script)
|
||||
})
|
||||
})
|
||||
|
||||
// 标注点数据
|
||||
const annotations = [
|
||||
// {
|
||||
// id: 'reception',
|
||||
// title: '接待大厅',
|
||||
// description: '医院的主要接待区域,提供咨询、挂号等服务',
|
||||
// area: '200平方米',
|
||||
// capacity: '可容纳50人',
|
||||
// function: '接待、咨询、挂号',
|
||||
// position: { x: 100, y: 100 },
|
||||
// image: '/images/reception.jpg'
|
||||
// },
|
||||
// {
|
||||
// id: 'emergency',
|
||||
// title: '急诊科',
|
||||
// description: '24小时开放的急诊医疗服务区域',
|
||||
// area: '150平方米',
|
||||
// capacity: '可同时处理10名患者',
|
||||
// function: '急诊医疗、急救处理',
|
||||
// position: { x: 300, y: 200 },
|
||||
// image: '/images/emergency.jpg'
|
||||
// },
|
||||
// {
|
||||
// id: 'pharmacy',
|
||||
// title: '药房',
|
||||
// description: '药品发放和咨询服务区域',
|
||||
// area: '80平方米',
|
||||
// capacity: '日处理500张处方',
|
||||
// function: '药品发放、用药咨询',
|
||||
// position: { x: 500, y: 150 },
|
||||
// image: '/images/pharmacy.jpg'
|
||||
// },
|
||||
// {
|
||||
// id: 'surgery',
|
||||
// title: '手术室',
|
||||
// description: '高标准无菌手术区域',
|
||||
// area: '120平方米',
|
||||
// capacity: '可同时进行3台手术',
|
||||
// function: '外科手术、微创手术',
|
||||
// position: { x: 200, y: 400 },
|
||||
// image: '/images/surgery.jpg'
|
||||
// },
|
||||
// {
|
||||
// id: 'ward',
|
||||
// title: '病房区',
|
||||
// description: '患者住院治疗和休养区域',
|
||||
// area: '300平方米',
|
||||
// capacity: '可容纳30张病床',
|
||||
// function: '住院治疗、护理服务',
|
||||
// position: { x: 400, y: 350 },
|
||||
// image: '/images/ward.jpg'
|
||||
// }
|
||||
]
|
||||
|
||||
// 摄像头数据
|
||||
const cameras = [
|
||||
|
||||
{
|
||||
id: 'camera4',
|
||||
name: '手术室监控',
|
||||
status: 'online',
|
||||
streamUrl: 'https://example.com/stream/camera4', // 替换为实际视频流地址
|
||||
location: '手术室外走廊',
|
||||
model: 'Dahua IPC-HDBW5842R-ZE',
|
||||
resolution: '8MP (3840×2160)',
|
||||
viewAngle: '360°',
|
||||
position: { x: 760, y: 320 },
|
||||
type: 'camera'
|
||||
},
|
||||
{
|
||||
id: 'camera5',
|
||||
name: '病房区监控',
|
||||
status: 'online',
|
||||
streamUrl: 'https://example.com/stream/camera5', // 替换为实际视频流地址
|
||||
location: '病房区走廊',
|
||||
model: 'Hikvision DS-2CD2386G2-IU',
|
||||
resolution: '8MP (3840×2160)',
|
||||
viewAngle: '110°',
|
||||
position: { x: 820, y: 330 },
|
||||
type: 'camera'
|
||||
}
|
||||
]
|
||||
|
||||
// 弹窗状态
|
||||
const showPopup = ref(false)
|
||||
const popupPosition = ref({ x: 0, y: 0 })
|
||||
const currentAnnotation = ref({})
|
||||
const currentCamera = ref({})
|
||||
const currentPopupType = ref('annotation') // 'annotation' 或 'camera'
|
||||
|
||||
// 显示区域信息弹窗
|
||||
const showAnnotationPopup = (annotation, event) => {
|
||||
currentAnnotation.value = annotation
|
||||
currentPopupType.value = 'annotation'
|
||||
|
||||
// 设置弹窗位置(在点击位置附近)
|
||||
const rect = mapContainer.value.getBoundingClientRect()
|
||||
popupPosition.value = {
|
||||
x: event.clientX - rect.left - 150, // 居中显示
|
||||
y: event.clientY - rect.top + 20
|
||||
}
|
||||
|
||||
// 确保弹窗不会超出地图容器
|
||||
if (popupPosition.value.x < 10) popupPosition.value.x = 10
|
||||
if (popupPosition.value.y < 10) popupPosition.value.y = 10
|
||||
if (popupPosition.value.x > rect.width - 320) popupPosition.value.x = rect.width - 320
|
||||
if (popupPosition.value.y > rect.height - 300) popupPosition.value.y = rect.height - 300
|
||||
|
||||
showPopup.value = true
|
||||
}
|
||||
|
||||
// 显示摄像头弹窗
|
||||
const showCameraPopup = (camera, event) => {
|
||||
currentCamera.value = camera
|
||||
currentPopupType.value = 'camera'
|
||||
|
||||
// 设置弹窗位置(在点击位置附近)
|
||||
const rect = mapContainer.value.getBoundingClientRect()
|
||||
popupPosition.value = {
|
||||
x: event.clientX - rect.left - 150, // 居中显示
|
||||
y: event.clientY - rect.top + 20
|
||||
}
|
||||
|
||||
// 确保弹窗不会超出地图容器
|
||||
if (popupPosition.value.x < 10) popupPosition.value.x = 10
|
||||
if (popupPosition.value.y < 10) popupPosition.value.y = 10
|
||||
if (popupPosition.value.x > rect.width - 320) popupPosition.value.x = rect.width - 320
|
||||
if (popupPosition.value.y > rect.height - 300) popupPosition.value.y = rect.height - 300
|
||||
|
||||
showPopup.value = true
|
||||
}
|
||||
|
||||
// 摄像头控制状态
|
||||
// const isCameraFullscreen = ref(false)
|
||||
// const isAudioMuted = ref(true)
|
||||
const cameraVideo = ref(null)
|
||||
|
||||
// 添加标注点到地图
|
||||
const addAnnotationsToMap = () => {
|
||||
if (!map) return
|
||||
|
||||
// 添加区域标注点
|
||||
annotations.forEach(annotation => {
|
||||
// 创建一个虚拟的标注点元素
|
||||
const markerElement = document.createElement('div')
|
||||
markerElement.className = 'annotation-marker'
|
||||
markerElement.innerHTML = `
|
||||
<div class="marker-dot" style="width: 20px; height: 20px; background: #ff6b6b; border: 3px solid white; border-radius: 50%; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.3);"></div>
|
||||
<div class="marker-label" style="position: absolute; top: -25px; left: 50%; transform: translateX(-50%); background: #ff6b6b; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap;">${annotation.title}</div>
|
||||
`
|
||||
|
||||
markerElement.style.position = 'absolute'
|
||||
markerElement.style.left = annotation.position.x + 'px'
|
||||
markerElement.style.top = annotation.position.y + 'px'
|
||||
markerElement.style.zIndex = '1000'
|
||||
markerElement.style.cursor = 'pointer'
|
||||
|
||||
// 添加点击事件
|
||||
markerElement.addEventListener('click', (event) => {
|
||||
event.stopPropagation()
|
||||
showAnnotationPopup(annotation, event)
|
||||
})
|
||||
|
||||
// 添加到地图容器
|
||||
mapContainer.value.appendChild(markerElement)
|
||||
})
|
||||
|
||||
// 添加摄像头标注点
|
||||
cameras.forEach(camera => {
|
||||
// 创建一个虚拟的摄像头标注点元素
|
||||
const cameraElement = document.createElement('div')
|
||||
cameraElement.className = 'camera-marker'
|
||||
cameraElement.innerHTML = `
|
||||
<div class="camera-icon" style="width: 24px; height: 24px; background: ${camera.status === 'online' ? '#4CAF50' : '#f44336'}; border: 3px solid white; border-radius: 50%; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; font-size: 12px; color: white;">📹</div>
|
||||
<div class="camera-label" style="position: absolute; top: -30px; left: 50%; transform: translateX(-50%); background: ${camera.status === 'online' ? '#4CAF50' : '#f44336'}; color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap;">${camera.name}</div>
|
||||
`
|
||||
|
||||
cameraElement.style.position = 'absolute'
|
||||
cameraElement.style.left = camera.position.x + 'px'
|
||||
cameraElement.style.top = camera.position.y + 'px'
|
||||
cameraElement.style.zIndex = '1000'
|
||||
cameraElement.style.cursor = 'pointer'
|
||||
|
||||
// 添加点击事件
|
||||
cameraElement.addEventListener('click', (event) => {
|
||||
event.stopPropagation()
|
||||
showCameraPopup(camera, event)
|
||||
})
|
||||
|
||||
// 添加到地图容器
|
||||
mapContainer.value.appendChild(cameraElement)
|
||||
})
|
||||
}
|
||||
|
||||
// 摄像头相关方法
|
||||
const closePopup = () => {
|
||||
showPopup.value = false
|
||||
currentPopupType.value = 'annotation'
|
||||
currentAnnotation.value = {}
|
||||
currentCamera.value = {}
|
||||
}
|
||||
|
||||
// 点击地图其他地方关闭弹窗
|
||||
const handleMapClick = () => {
|
||||
if (showPopup.value) {
|
||||
closePopup()
|
||||
}
|
||||
}
|
||||
|
||||
const handleVideoError = () => {
|
||||
console.error('摄像头视频加载失败')
|
||||
}
|
||||
|
||||
|
||||
onUnmounted(() => {
|
||||
// 清理事件监听器
|
||||
window.removeEventListener('resize', handleResize)
|
||||
|
||||
// 清理地图点击事件监听
|
||||
if (mapContainer.value) {
|
||||
mapContainer.value.removeEventListener('click', handleMapClick)
|
||||
}
|
||||
|
||||
// 清理组件实例
|
||||
if (floorsComp) {
|
||||
floorsComp.unbind && floorsComp.unbind()
|
||||
floorsComp = null
|
||||
}
|
||||
|
||||
// 清理地图实例
|
||||
if (map) {
|
||||
map.destroy && map.destroy()
|
||||
map = null
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.map-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 800px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.map {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.controls {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.controls button {
|
||||
padding: 8px 16px;
|
||||
background: #fff;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.controls button:hover {
|
||||
background: #f5f5f5;
|
||||
border-color: #999;
|
||||
}
|
||||
|
||||
.controls button:active {
|
||||
background: #e5e5e5;
|
||||
}
|
||||
|
||||
/* 标注点样式 */
|
||||
.annotation-marker {
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.annotation-marker:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.annotation-marker .marker-dot {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.annotation-marker:hover .marker-dot {
|
||||
background: #ff5252 !important;
|
||||
box-shadow: 0 4px 12px rgba(255, 82, 82, 0.4) !important;
|
||||
}
|
||||
|
||||
.annotation-marker .marker-label {
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.annotation-marker:hover .marker-label {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* 摄像头标注点样式 */
|
||||
.camera-marker {
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.camera-marker:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.camera-marker .camera-icon {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.camera-marker:hover .camera-icon {
|
||||
transform: scale(1.2);
|
||||
box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4) !important;
|
||||
}
|
||||
|
||||
.camera-marker .camera-label {
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.camera-marker:hover .camera-label {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* 摄像头弹窗样式 */
|
||||
.camera-popup {
|
||||
position: absolute;
|
||||
width: 400px;
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
||||
z-index: 2000;
|
||||
animation: popupFadeIn 0.3s ease;
|
||||
}
|
||||
|
||||
.camera-popup .popup-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 15px 20px;
|
||||
background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
|
||||
color: white;
|
||||
border-radius: 12px 12px 0 0;
|
||||
}
|
||||
|
||||
.camera-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: #f44336;
|
||||
}
|
||||
|
||||
.status-dot.online {
|
||||
background: #4CAF50;
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% { opacity: 1; }
|
||||
50% { opacity: 0.5; }
|
||||
100% { opacity: 1; }
|
||||
}
|
||||
|
||||
.status-text {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.camera-popup .popup-content {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.video-container {
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
background: #000;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.camera-video {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.offline-placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.offline-icon {
|
||||
font-size: 48px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.camera-info {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.info-item .label {
|
||||
color: #999;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.info-item .value {
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.camera-controls {
|
||||
display: flex;
|
||||
gap: 100px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.control-btn {
|
||||
padding: 8px 16px;
|
||||
background: #2196F3;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
|
||||
.control-btn:hover {
|
||||
background: #1976D2;
|
||||
}
|
||||
|
||||
.control-btn:active {
|
||||
background: #1565C0;
|
||||
}
|
||||
</style>
|
||||
4
src/main.js
Normal file
4
src/main.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
|
||||
createApp(App).mount('#app')
|
||||
Reference in New Issue
Block a user