This commit is contained in:
wgf
2026-03-27 09:02:29 +08:00
parent d9531fc042
commit f777b162c2
13 changed files with 1522 additions and 1414 deletions

88
App.vue
View File

@@ -1,88 +0,0 @@
<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>

View File

@@ -1,277 +0,0 @@
<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>

View File

@@ -1,624 +0,0 @@
<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>

101
OOOMAP_RESOURCES.md Normal file
View File

@@ -0,0 +1,101 @@
# ooomap 资源文件说明
## 所需资源文件
本项目使用 ooomap 3D地图库需要以下资源文件才能正常运行
### 1. ooomap 主库文件
- **位置**: `public/lib/ooomap.min.js`
- **说明**: ooomap 核心库文件
- **获取方式**:
- 从 ooomap 官方网站下载: https://www.ooomap.com
- 或从您的 ooomap 项目中复制
### 2. ooomap 日志文件
- **位置**: `public/js/ooomapLog.js`
- **说明**: ooomap 日志记录脚本
- **获取方式**:
- 从 ooomap 官方网站下载
- 或从您的 ooomap 项目中复制
### 3. 医院模型文件
- **位置**: `public/models/hospital/glb/`
- **说明**: 医院建筑的3D模型文件GLB格式
- **获取方式**:
- 从 ooomap 编辑器导出
- 或从您的 ooomap 项目中复制
### 4. 模型数据配置文件
- **位置**: `public/models/hospital/modelsData.json`
- **说明**: 模型数据的配置文件
- **获取方式**:
- 从 ooomap 编辑器导出
- 或从您的 ooomap 项目中复制
## 目录结构
```
public/
├── lib/
│ └── ooomap.min.js # ooomap 核心库
├── js/
│ └── ooomapLog.js # ooomap 日志脚本
├── models/
│ └── hospital/
│ ├── glb/ # 3D模型文件目录
│ │ ├── floor1.glb
│ │ ├── floor2.glb
│ │ └── ...
│ └── modelsData.json # 模型数据配置
├── favicon.ico
├── index.html
└── zhenggui.png
```
## 如何获取资源文件
### 方法1: 从 ooomap 官方获取
1. 访问 ooomap 官方网站: https://www.ooomap.com
2. 注册并登录账户
3. 创建或打开一个项目
4. 导出所需的资源文件
### 方法2: 从现有项目复制
如果您已经有使用 ooomap 的项目,可以直接从该项目中复制所需的资源文件。
### 方法3: 使用 CDN如果可用
某些 ooomap 资源可能通过 CDN 提供,您可以修改组件代码使用 CDN 链接。
## 注意事项
1. **文件路径**: 确保所有文件的路径与代码中的引用路径一致
2. **文件大小**: 3D模型文件可能较大请确保有足够的存储空间
3. **跨域问题**: 如果从外部服务器加载资源,可能需要配置 CORS
4. **版本兼容**: 确保使用的 ooomap 库版本与模型文件兼容
## 故障排除
### 问题: "ooomap主库加载失败"
**解决方案**:
- 检查 `public/lib/ooomap.min.js` 文件是否存在
- 确认文件路径正确
- 检查文件是否损坏
### 问题: "模型加载失败"
**解决方案**:
- 检查 `public/models/hospital/glb/` 目录中的模型文件
- 确认 `modelsData.json` 配置文件存在且格式正确
- 检查模型文件路径是否与配置文件中的路径一致
### 问题: 地图显示空白
**解决方案**:
- 检查浏览器控制台是否有错误信息
- 确认所有必需的资源文件都已正确加载
- 检查网络请求是否成功
## 联系支持
如果您在获取或配置资源文件时遇到问题,可以:
- 访问 ooomap 官方文档: https://www.ooomap.com/docs
- 联系 ooomap 技术支持
- 查看项目 GitHub 仓库的 Issues

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -1,17 +0,0 @@
<!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
logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -1,4 +0,0 @@
import { createApp } from 'vue'
import App from './App.vue'
createApp(App).mount('#app')

84
package-lock.json generated
View File

@@ -1862,49 +1862,6 @@
"webpack-merge": "^5.7.3", "webpack-merge": "^5.7.3",
"webpack-virtual-modules": "^0.4.2", "webpack-virtual-modules": "^0.4.2",
"whatwg-fetch": "^3.6.2" "whatwg-fetch": "^3.6.2"
},
"dependencies": {
"@vue/vue-loader-v15": {
"version": "npm:vue-loader@15.11.1",
"resolved": "https://registry.npmmirror.com/vue-loader/-/vue-loader-15.11.1.tgz",
"integrity": "sha512-0iw4VchYLePqJfJu9s62ACWUXeSqM30SQqlIftbYWM3C+jpPcEHKSPUZBLjSF9au4HTHQ/naF6OGnO3Q/qGR3Q==",
"dev": true,
"requires": {
"@vue/component-compiler-utils": "^3.1.0",
"hash-sum": "^1.0.2",
"loader-utils": "^1.1.0",
"vue-hot-reload-api": "^2.3.0",
"vue-style-loader": "^4.1.0"
},
"dependencies": {
"hash-sum": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/hash-sum/-/hash-sum-1.0.2.tgz",
"integrity": "sha512-fUs4B4L+mlt8/XAtSOGMUO1TXmAelItBPtJG7CyHJfYTdDjwisntGO2JQz7oUsatOY9o68+57eziUVNw/mRHmA==",
"dev": true
}
}
},
"json5": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/json5/-/json5-1.0.2.tgz",
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
}
},
"loader-utils": {
"version": "1.4.2",
"resolved": "https://registry.npmmirror.com/loader-utils/-/loader-utils-1.4.2.tgz",
"integrity": "sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==",
"dev": true,
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^1.0.1"
}
}
} }
}, },
"@vue/cli-shared-utils": { "@vue/cli-shared-utils": {
@@ -2100,6 +2057,47 @@
"resolved": "https://registry.npmmirror.com/@vue/shared/-/shared-3.5.29.tgz", "resolved": "https://registry.npmmirror.com/@vue/shared/-/shared-3.5.29.tgz",
"integrity": "sha512-w7SR0A5zyRByL9XUkCfdLs7t9XOHUyJ67qPGQjOou3p6GvBeBW+AVjUUmlxtZ4PIYaRvE+1LmK44O4uajlZwcg==" "integrity": "sha512-w7SR0A5zyRByL9XUkCfdLs7t9XOHUyJ67qPGQjOou3p6GvBeBW+AVjUUmlxtZ4PIYaRvE+1LmK44O4uajlZwcg=="
}, },
"@vue/vue-loader-v15": {
"version": "npm:vue-loader@15.11.1",
"resolved": "https://registry.npmmirror.com/vue-loader/-/vue-loader-15.11.1.tgz",
"integrity": "sha512-0iw4VchYLePqJfJu9s62ACWUXeSqM30SQqlIftbYWM3C+jpPcEHKSPUZBLjSF9au4HTHQ/naF6OGnO3Q/qGR3Q==",
"dev": true,
"requires": {
"@vue/component-compiler-utils": "^3.1.0",
"hash-sum": "^1.0.2",
"loader-utils": "^1.1.0",
"vue-hot-reload-api": "^2.3.0",
"vue-style-loader": "^4.1.0"
},
"dependencies": {
"hash-sum": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/hash-sum/-/hash-sum-1.0.2.tgz",
"integrity": "sha512-fUs4B4L+mlt8/XAtSOGMUO1TXmAelItBPtJG7CyHJfYTdDjwisntGO2JQz7oUsatOY9o68+57eziUVNw/mRHmA==",
"dev": true
},
"json5": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/json5/-/json5-1.0.2.tgz",
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
}
},
"loader-utils": {
"version": "1.4.2",
"resolved": "https://registry.npmmirror.com/loader-utils/-/loader-utils-1.4.2.tgz",
"integrity": "sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==",
"dev": true,
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^1.0.1"
}
}
}
},
"@vue/web-component-wrapper": { "@vue/web-component-wrapper": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmmirror.com/@vue/web-component-wrapper/-/web-component-wrapper-1.3.0.tgz", "resolved": "https://registry.npmmirror.com/@vue/web-component-wrapper/-/web-component-wrapper-1.3.0.tgz",

7
public/js/ooomap.xcx.min.js vendored Normal file

File diff suppressed because one or more lines are too long

BIN
src/assets/gongren.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -1,277 +1,729 @@
<template> <template>
<div class="campus-map-container"> <div class="map-container">
<div ref="mapContainer" class="campus-map"></div> <div ref="mapContainer" class="map"></div>
<div class="map-controls"> <!-- 路径信息显示 -->
<button @click="goToBuildingDetail" class="control-btn">进入建筑详情</button> <div v-if= routeInfo.show class="route-info-panel">
<button @click="resetView" class="control-btn">重置视图</button> <div class="route-header">
<h3>路径信息</h3>
<button @click="closeRouteInfo" class="close-btn">×</button>
</div>
<div class="route-content">
<div class="route-item">
<span class="label">总距离</span>
<span class="value">{{ routeInfo.distance }} </span>
</div>
<div class="route-item">
<span class="label">预计时间</span>
<span class="value">{{ routeInfo.time }}</span>
</div>
<div class="route-item">
<span class="label">平均速度</span>
<span class="value">{{ routeInfo.speed }} /</span>
</div>
</div>
</div> </div>
</div> </div>
</template> </template>
<script> <script setup>
import L from 'leaflet' /* eslint-disable no-unused-vars */
import 'leaflet/dist/leaflet.css' /* global om */
import { ref, onMounted, onUnmounted ,defineEmits} from 'vue'
export default { const emit = defineEmits(['navigate'])
name: 'CampusMap', const mapContainer = ref(null)
emits: ['navigate'], let map = null
data() { let floorsComp = null
return { let pickCount = 0
map: null, let building = null
mapConfig: { let from = null
// 园区地图的边界坐标(使用更合理的默认尺寸) let to = null
imageWidth: 1200, // 假设图片宽度 let startMarker = null
imageHeight: 800, // 假设图片高度 let endMarker = null
// 标点位置(使用相对位置,更容易看到) let markerName = ref('')
markers: [
{ id: 'building1', position: [530, 280], name: '建筑A', target: 'helloWorld' }, const routeInfo = ref({
{ id: 'building2', position: [800, 500], name: '建筑B', target: 'helloWorld' } show: false,
] distance: 0,
time: '',
speed: 1.2
})
// 从2.html中提取的配置参数
const mapConfig = {
verifyUrl: 'https://www.ooomap.com/ooomap-verify/check/13b7e6de01570b42ae2a686c1253756d',
appID: '3c4caa9aeb0a89a1c731308956bee252',
}
const showMarkerInfo=(marker)=> {
console.log('888',marker)
// 获取标注信息
if(marker.type =='OMBlock'){
const name = marker.data.id || '未命名标注'
console.log('name',name)
if(marker.data.id == '1mhfj2kmgh1r02n0'){
console.log('点击了起点')
emit('navigate', 'helloWorld')
}
markerName.value = name
console.log('2323',name)
}
}
const calculateRouteTime = (routeResult) => {
let totalDistance = 0
for (let i = 0; i < routeResult.vectors[0].length - 1; i++) {
const p1 = routeResult.vectors[0][i]
const p2 = routeResult.vectors[0][i + 1]
if (p1 && p2) {
const dx = p2.x - p1.x
const dy = p2.y - p1.y
totalDistance += Math.sqrt(dx * dx + dy * dy)
} }
} }
},
mounted() {
this.initMap()
},
beforeUnmount() {
if (this.map) {
this.map.remove()
this.map = null
}
},
methods: {
initMap() {
if (!this.$refs.mapContainer) return
// 创建地图实例 const walkingSpeed = routeInfo.value.speed
this.map = L.map(this.$refs.mapContainer, { const timeInSeconds = totalDistance / walkingSpeed
crs: L.CRS.Simple, // 使用简单坐标系
minZoom: -2, const minutes = Math.floor(timeInSeconds / 60)
maxZoom: 4 const seconds = Math.round(timeInSeconds % 60)
let timeString = ''
if (minutes > 0) {
timeString = `${minutes}${seconds}`
} else {
timeString = `${seconds}`
}
routeInfo.value.distance = Math.round(totalDistance * 100) / 100
routeInfo.value.time = timeString
routeInfo.value.show = true
console.log('路径计算结果:', {
距离: routeInfo.value.distance + '米',
时间: routeInfo.value.time,
速度: walkingSpeed + ' 米/秒'
})
}
const closeRouteInfo = () => {
routeInfo.value.show = false
}
const initMap = () => {
try {
// 初始化ooomap实例 - 使用2.html中的配置
map = new window.om.Map({
container: mapContainer.value,
verifyUrl: mapConfig.verifyUrl,
appID: mapConfig.appID
})
// 创建标记函数
const createMarker = (url) => {
const marker = new window.om.SpriteMarkerNode(map, {
type: 'poi',
autoHide: false,
priority: 10,
renderOrder: 3,
content: {
image: {
url: url,
width: 60,
height: 60
}
}
}) })
// 使用配置的图片尺寸 // 先将标注隐藏, 在点击起/终点时再显示出来
const imageWidth = this.mapConfig.imageWidth marker.show = false
const imageHeight = this.mapConfig.imageHeight map.omScene.markerNode.add(marker)
return marker
// 设置地图边界
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)
}
} }
// 建筑加载完成事件
map.on('buildingLoaded', b => {
building = b
// 创建起终点marker
startMarker = createMarker('https://www.ooomap.com/assets/map_images/start2.png')
endMarker = createMarker('https://www.ooomap.com/assets/map_images/end2.png')
})
// 拾取地图中的对象
map.on('picked', result => {
const node = result.node
console.log('点击的对象:', node)
if(node.type == 'OMBlock'){
showMarkerInfo(node, result.position)
}
// 只针对 POI 对象
if (!node || node.type !== 'SpriteMarkerNode') {
if (building) {
building.clearRoutes()
startMarker.show = endMarker.show = false
}
return
}
console.log(node)
node.flash()
// 先得到此结点的所有父级, 知道他是属于哪个楼层, 哪个建筑
// ancestor: {buildingID: string, floorNumber: int, building: OMBuilding, floor: OMFloor}
const ancestor = node.getAncestor()
// 拾取点计数
pickCount++
// 当拾取2个点后, 创建路径
if (pickCount % 2 === 0) {
pickCount = 0
// 到达点的数据
to = {
floorNumber: ancestor.floorNumber,
point: node.position.clone()
}
endMarker.position = node.position
ancestor.floor.markerNode.add(endMarker)
endMarker.show = true
// 得到两点间的最优路线
building.findPath(from, to).then(res => {
console.log('routeResult: ', res)
calculateRouteTime(res)
})
} else {
// 先清空之前的路径线
building.clearRoutes()
// 起始点数据, 生成的路径线较楼板的高度为 1米
from = {
floorNumber: ancestor.floorNumber,
point: node.position.clone()
}
console.log('startMarker.position',startMarker.position)
startMarker.position = node.position
ancestor.floor.markerNode.add(startMarker)
startMarker.show = true
endMarker.show = false
}
})
window.addEventListener('resize', () => {
map.view.resize()
})
} 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 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 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)
})
}
// 摄像头相关方法
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> </script>
<style scoped> <style scoped>
.campus-map-container { .map-container {
position: relative; position: relative;
width: 100%; width: 100%;
height: 100vh; height: 800px;
border: 1px solid #ccc;
border-radius: 8px;
overflow: hidden; overflow: hidden;
} }
.campus-map { .map {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.map-controls { .controls {
position: absolute; position: absolute;
top: 20px; top: 20px;
right: 20px; right: 20px;
z-index: 1000; z-index: 1000;
display: flex; display: flex;
flex-direction: column;
gap: 10px; gap: 10px;
} }
.control-btn { .controls button {
padding: 10px 16px; padding: 8px 16px;
background: #fff; background: #fff;
border: 2px solid #1890ff; border: 1px solid #ddd;
border-radius: 6px; border-radius: 4px;
color: #1890ff;
cursor: pointer; cursor: pointer;
font-size: 14px; font-size: 14px;
font-weight: 500;
transition: all 0.3s ease; transition: all 0.3s ease;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); }
.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 { .control-btn:hover {
background: #1890ff; background: #1976D2;
color: #fff;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(24, 144, 255, 0.4);
} }
.control-btn:active { .control-btn:active {
transform: translateY(0); background: #1565C0;
} }
/* 自定义标记样式 */ /* 路径信息面板样式 */
.custom-marker { .route-info-panel {
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; position: absolute;
top: -25px; top: 20px;
left: 50%; left: 20px;
transform: translateX(-50%); background: white;
background: #fff; border-radius: 8px;
padding: 4px 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
border-radius: 4px; z-index: 1000;
font-size: 12px; min-width: 280px;
font-weight: bold; overflow: hidden;
white-space: nowrap;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
border: 1px solid #ddd;
} }
.marker-hover .marker-pin { .route-header {
background: #ff5252; display: flex;
transform: rotate(-45deg) scale(1.1); justify-content: space-between;
align-items: center;
padding: 12px 16px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
} }
.marker-hover .marker-label { .route-header h3 {
background: #1890ff; margin: 0;
color: #fff; font-size: 16px;
font-weight: 600;
} }
/* Leaflet 样式调整 */ .route-header .close-btn {
:deep(.leaflet-control-zoom) { background: rgba(255, 255, 255, 0.2);
border: none; border: none;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); color: white;
width: 28px;
height: 28px;
border-radius: 50%;
font-size: 20px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.3s ease;
} }
:deep(.leaflet-control-zoom a) { .route-header .close-btn:hover {
background: #fff; background: rgba(255, 255, 255, 0.3);
border: none; }
.route-content {
padding: 16px;
}
.route-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 0;
border-bottom: 1px solid #f0f0f0;
}
.route-item:last-child {
border-bottom: none;
}
.route-item .label {
color: #666;
font-size: 14px;
}
.route-item .value {
color: #333; color: #333;
font-weight: bold; font-size: 14px;
} font-weight: 600;
:deep(.leaflet-control-zoom a:hover) {
background: #f5f5f5;
} }
</style> </style>

View File

@@ -1,59 +1,116 @@
<template> <template>
<div class="map-container"> <div class="map-container">
<div ref="mapContainer" class="map"></div> <div ref="mapContainer" class="map"></div>
<div v-if="routeInfo.show" class="route-info-panel">
<!-- 摄像头监控弹窗 --> <div class="route-header">
<div v-if="showPopup && currentPopupType === 'camera'" class="camera-popup" :style="{ top: popupPosition.y + 'px', left: popupPosition.x + 'px' }"> <h3>路径信息</h3>
<div class="popup-header"> <button @click="closeRouteInfo" class="close-btn">×</button>
<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>
<div class="route-content">
<div class="route-item">
<span class="label">总距离</span>
<span class="value">{{ routeInfo.distance }} </span>
</div>
<div class="route-item">
<span class="label">预计时间</span>
<span class="value">{{ routeInfo.time }}</span>
</div>
<div class="route-item">
<span class="label">平均速度</span>
<span class="value">{{ routeInfo.speed }} /</span>
</div>
</div>
</div>
<!-- 摄像头监控弹窗 -->
<div v-if="showMarkerPopup" class="marker-popup bottom-fixed">
<div class="popup-arrow"></div>
<div class="popup-content"> <div class="popup-content">
<div class="video-container"> <button @click="closeMarkerPopup" class="close-popup-btn">×</button>
<video <div class="popup-main">
v-if="currentCamera.status === 'online'" <div class="popup-center">
ref="cameraVideo" <text class="marker-name">{{ markerName }}</text>
:src="currentCamera.streamUrl" <text class="marker-desc">{{ markerDesc }}</text>
autoplay </div>
muted <div class="popup-right">
controls <text class="camera-info">{{ cameraInfo }}</text>
class="camera-video"
@error="handleVideoError"
>
您的浏览器不支持视频播放
</video>
<div v-else class="offline-placeholder">
<div class="offline-icon">📹</div>
<p>摄像头离线</p>
</div> </div>
</div> </div>
<!-- <!-- 摄像头列表 -->
<div class="camera-controls"> <div v-if="cameras.length > 0" class="camera-list">
<button @click="toggleCameraFullscreen" class="control-btn"> <h4>监控摄像头</h4>
{{ isCameraFullscreen ? '退出全屏' : '全屏' }} <div class="camera-items">
</button> <div
<button @click="takeScreenshot" class="control-btn">截图</button> v-for="camera in cameras"
<button @click="toggleCameraAudio" class="control-btn"> :key="camera.id"
{{ isAudioMuted ? '开启声音' : '静音' }} class="camera-item"
</button> @click="playCamera(camera.streamUrl)"
</div> --> >
<div class="camera-icon">📹</div>
<div class="camera-details">
<div class="camera-name">{{ camera.name }}</div>
<div class="camera-status" :class="camera.status">
{{ camera.status === 'online' ? '在线' : '离线' }}
</div>
</div>
<div class="play-icon"></div>
</div>
</div>
</div>
</div>
</div>
<!-- 视频播放弹窗 -->
<div v-if="showCameraVideo" class="camera-video-overlay">
<div class="video-container">
<div class="video-header">
<h3>实时监控</h3>
<button @click="closeCameraVideo" class="close-video-btn">×</button>
</div>
<video
:src="currentCameraStream"
controls
autoplay
class="video-player"
>
您的浏览器不支持视频播放
</video>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
/* eslint-disable no-unused-vars */
/* global om */
import { ref, onMounted, onUnmounted } from 'vue' import { ref, onMounted, onUnmounted } from 'vue'
const mapContainer = ref(null) const mapContainer = ref(null)
let map = null let map = null
let floorsComp = null let floorsComp = null
const showMarkerPopup = ref(false)
const markerName = ref('')
const markerDesc = ref('')
const markerImage = ref('')
const cameraInfo = ref('')
// 从2.html中提取的配置参数 // 摄像头列表
const cameras = ref([])
const showCameraVideo = ref(false)
const currentCameraStream = ref('')
const routeInfo = ref({
show: false,
distance: 0,
time: '',
speed: 1.2
})
let pickCount = 0
let building = null
let from = null
let to = null
let startMarker = null
let endMarker = null
// 从 2.html 中提取的配置参数
const mapConfig = { const mapConfig = {
verifyUrl: 'https://www.ooomap.com/ooomap-verify/check/50689bb01e0ac2a9d93bb18f1e1260f8', verifyUrl: 'https://www.ooomap.com/ooomap-verify/check/50689bb01e0ac2a9d93bb18f1e1260f8',
appID: '87ae6a00e5ca4e33dd7e858a66b73475' appID: '87ae6a00e5ca4e33dd7e858a66b73475'
@@ -99,7 +156,6 @@ const initMap = () => {
}) })
floorsComp.bind(map) floorsComp.bind(map)
} }
// 窗口大小变化时调整地图视图 // 窗口大小变化时调整地图视图
window.addEventListener('resize', handleResize) window.addEventListener('resize', handleResize)
@@ -107,12 +163,10 @@ const initMap = () => {
map.on('load', () => { map.on('load', () => {
console.log('ooomap加载完成') console.log('ooomap加载完成')
}) })
// 错误处理 // 错误处理
map.on('error', (error) => { map.on('error', (error) => {
console.error('ooomap加载错误:', error) console.error('ooomap加载错误:', error)
}) })
} catch (error) { } catch (error) {
console.error('初始化ooomap失败:', error) console.error('初始化ooomap失败:', error)
} }
@@ -123,7 +177,62 @@ const handleResize = () => {
map.view.resize() map.view.resize()
} }
} }
const createMarker = (url) => {
const marker = new window.om.SpriteMarkerNode(map, {
type: 'poi',
autoHide: false,
priority: 10,
renderOrder: 3,
content: {
image: {
url: url,
width: 60,
height: 60
}
}
})
// 先将标注隐藏, 在点击起/终点时再显示出来
marker.show = false
map.omScene.markerNode.add(marker)
return marker
}
const calculateRouteTime = (routeResult) => {
let totalDistance = 0
console.log('routeResult1',routeResult.vectors[0].length)
for (let i = 0; i < routeResult.vectors[0].length - 1; i++) {
const p1 = routeResult.vectors[0][i]
const p2 = routeResult.vectors[0][i + 1]
if (p1 && p2) {
const dx = p2.x - p1.x
const dy = p2.y - p1.y
totalDistance += Math.sqrt(dx * dx + dy * dy)
}
}
console.log('totalDistance',totalDistance)
const walkingSpeed = routeInfo.value.speed
const timeInSeconds = totalDistance / walkingSpeed
const minutes = Math.floor(timeInSeconds / 60)
const seconds = Math.round(timeInSeconds % 60)
let timeString = ''
if (minutes > 0) {
timeString = `${minutes}${seconds}`
} else {
timeString = `${seconds}`
}
routeInfo.value.distance = Math.round(totalDistance * 100) / 100
routeInfo.value.time = timeString
routeInfo.value.show = true
console.log('路径计算结果:', {
距离: routeInfo.value.distance + ' 米',
时间: routeInfo.value.time,
速度: walkingSpeed + ' 米/秒'
})
}
@@ -142,10 +251,128 @@ onMounted(() => {
script.onload = () => { script.onload = () => {
loadedCount++ loadedCount++
if (loadedCount === scripts.length) { if (loadedCount === scripts.length) {
console.log('所有ooomap SDK加载完成') console.log('所有 ooomap SDK 加载完成')
initMap() initMap()
// 地图加载完成后添加标注点 map.on('sceneLoaded', scene => {
addAnnotationsToMap() console.log('场景加载成功', scene)
var planeMarker1 = new window.om.PlaneMarkerNode(map, {
url: 'https://img1.baidu.com/it/u=794006712,1137416170&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
size: [20, 20],
fixedSize: true,
position: [4, 6, 5]
})
scene.markerNode.add(planeMarker1)
// 创建示例标注 - 急诊科
var planeMarker2 = new window.om.PlaneMarkerNode(map, {
url: 'https://img1.baidu.com/it/u=794006712,1137416170&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
size: [20, 20],
fixedSize: true,
position: [12, 6, 5]
})
planeMarker2.name = "摄像头"
planeMarker2.desc = "监控"
scene.markerNode.add(planeMarker2)
var planeMarker3 = new window.om.PlaneMarkerNode(map, {
url: 'https://img1.baidu.com/it/u=794006712,1137416170&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
size: [20, 20],
fixedSize: true,
position: [-4, 6, 5]
})
// planeMarker2.image = "https://www.ooomap.com/assets/map_images/ooomap-logo.png"
scene.markerNode.add(planeMarker3)
var planeMarker4 = new window.om.PlaneMarkerNode(map, {
url: 'https://t8.baidu.com/it/u=1806295336,191717518&fm=193',
size: [20, 30],
fixedSize: true,
position: [12, 0, 6]
})
planeMarker4.data.content.name = "工人"
planeMarker4.data.content.desc = "正在干活的工人"
// planeMarker2.image = "https://www.ooomap.com/assets/map_images/ooomap-logo.png"
scene.markerNode.add(planeMarker4)
var planeMarker5 = new window.om.PlaneMarkerNode(map, {
url: 'https://img0.baidu.com/it/u=4156439281,873830688&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
size: [30, 30],
fixedSize: true,
position: [4, 0, 6]
})
planeMarker5.data.content.name = "硬件"
planeMarker5.data.content.desc = "正在工作的硬件"
scene.markerNode.add(planeMarker5)
})
map.on('buildingLoaded', b => {
building = b
// 创建起终点marker
startMarker = createMarker('https://www.ooomap.com/assets/map_images/start2.png')
endMarker = createMarker('https://www.ooomap.com/assets/map_images/end2.png')
})
map.on('picked', result => {
const node = result.node
console.log('点击的对象:', node)
console.log('点击的位置:', result)
if(node.type == 'SpriteMarkerNode' || node.type == 'PlaneMarkerNode'){
showMarkerInfo(node, result.position)
}
if(node.data.url == "https://img1.baidu.com/it/u=794006712,1137416170&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500"){
// showMarkerInfo(node, result.position)
playCamera('https://www.w3schools.com/html/mov_bbb.mp4')
}
// 只针对 POI 对象SpriteMarkerNode进行路径规划
if (!node || node.type !== 'SpriteMarkerNode') {
if (building) {
building.clearRoutes()
startMarker.show = endMarker.show = false
}
return
}
node.flash()
// 先得到此结点的所有父级, 知道他是属于哪个楼层, 哪个建筑
const ancestor = node.getAncestor()
// 拾取点计数
pickCount++
// 当拾取2个点后, 创建路径
if (pickCount % 2 === 0) {
pickCount = 0
// 到达点的数据
to = {
floorNumber: ancestor.floorNumber,
point: node.position.clone()
}
endMarker.position = node.position
ancestor.floor.markerNode.add(endMarker)
endMarker.show = true
// 得到两点间的最优路线
building.findPath(from, to).then(res => {
console.log('routeResult: ', res)
calculateRouteTime(res)
})
} else {
// 先清空之前的路径线
building.clearRoutes()
// 起始点数据, 生成的路径线较楼板的高度为 1米
from = {
floorNumber: ancestor.floorNumber,
point: node.position.clone()
}
console.log('startMarker.position',startMarker.position)
startMarker.position = node.position
ancestor.floor.markerNode.add(startMarker)
startMarker.show = true
endMarker.show = false
}
})
// 添加地图点击事件监听 // 添加地图点击事件监听
mapContainer.value.addEventListener('click', handleMapClick) mapContainer.value.addEventListener('click', handleMapClick)
} }
@@ -156,6 +383,50 @@ onMounted(() => {
document.head.appendChild(script) document.head.appendChild(script)
}) })
}) })
const showMarkerInfo=(marker) =>{
console.log('888',marker)
// 获取标注信息
if(marker.type =='SpriteMarkerNode'){
const name = marker.data.content.texts[0] || '工人'
const desc = marker.data.content.desc || '未标明注释'
const camera = marker.camera || ''
markerName.value = name
markerDesc.value = desc
cameraInfo.value = camera
showMarkerPopup.value = true
}else if(marker.type =='PlaneMarkerNode'){
const name = marker.data.content.name || '工人'
const desc = marker.data.content.desc || '工人干活'
const camera = marker.camera || ''
markerName.value = name
markerDesc.value = desc
cameraInfo.value = camera
showMarkerPopup.value = true
}
}
// 播放摄像头视频
const playCamera = (streamUrl) => {
currentCameraStream.value = streamUrl
showCameraVideo.value = true
}
// 关闭视频播放
const closeCameraVideo = () => {
showCameraVideo.value = false
currentCameraStream.value = ''
}
// 关闭标注弹窗
const closeMarkerPopup = () => {
showMarkerPopup.value = false
cameras.value = []
}
// 关闭路径信息
const closeRouteInfo = () => {
routeInfo.value.show = false
}
// 标注点数据 // 标注点数据
const annotations = [ const annotations = [
@@ -195,7 +466,7 @@ const annotations = [
// description: '高标准无菌手术区域', // description: '高标准无菌手术区域',
// area: '120平方米', // area: '120平方米',
// capacity: '可同时进行3台手术', // capacity: '可同时进行3台手术',
// function: '外科手术、微创手术', // function: '外科手术、微4创手术',
// position: { x: 200, y: 400 }, // position: { x: 200, y: 400 },
// image: '/images/surgery.jpg' // image: '/images/surgery.jpg'
// }, // },
@@ -212,33 +483,33 @@ const annotations = [
] ]
// 摄像头数据 // 摄像头数据
const cameras = [ // const cameras = [
{ // {
id: 'camera4', // id: 'camera4',
name: '手术室监控', // name: '手术室监控',
status: 'online', // status: 'online',
streamUrl: 'https://example.com/stream/camera4', // 替换为实际视频流地址 // streamUrl: 'https://example.com/stream/camera4', // 替换为实际视频流地址
location: '手术室外走廊', // location: '手术室外走廊',
model: 'Dahua IPC-HDBW5842R-ZE', // model: 'Dahua IPC-HDBW5842R-ZE',
resolution: '8MP (3840×2160)', // resolution: '8MP (3840×2160)',
viewAngle: '360°', // viewAngle: '360°',
position: { x: 760, y: 320 }, // position: { x: 760, y: 320 },
type: 'camera' // type: 'camera'
}, // },
{ // {
id: 'camera5', // id: 'camera5',
name: '病房区监控', // name: '病房区监控',
status: 'online', // status: 'online',
streamUrl: 'https://example.com/stream/camera5', // 替换为实际视频流地址 // streamUrl: 'https://example.com/stream/camera5', // 替换为实际视频流地址
location: '病房区走廊', // location: '病房区走廊',
model: 'Hikvision DS-2CD2386G2-IU', // model: 'Hikvision DS-2CD2386G2-IU',
resolution: '8MP (3840×2160)', // resolution: '8MP (3840×2160)',
viewAngle: '110°', // viewAngle: '110°',
position: { x: 820, y: 330 }, // position: { x: 820, y: 330 },
type: 'camera' // type: 'camera'
} // }
] // ]
// 弹窗状态 // 弹窗状态
const showPopup = ref(false) const showPopup = ref(false)
@@ -264,12 +535,11 @@ const showAnnotationPopup = (annotation, event) => {
if (popupPosition.value.y < 10) popupPosition.value.y = 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.x > rect.width - 320) popupPosition.value.x = rect.width - 320
if (popupPosition.value.y > rect.height - 300) popupPosition.value.y = rect.height - 300 if (popupPosition.value.y > rect.height - 300) popupPosition.value.y = rect.height - 300
showPopup.value = true showPopup.value = true
} }
// 显示摄像头弹窗 // 显示摄像头弹窗
const showCameraPopup = (camera, event) => { const showCameraPopup = (camera, event) => {
currentCamera.value = camera currentCamera.value = camera
currentPopupType.value = 'camera' currentPopupType.value = 'camera'
@@ -285,70 +555,13 @@ const showCameraPopup = (camera, event) => {
if (popupPosition.value.y < 10) popupPosition.value.y = 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.x > rect.width - 320) popupPosition.value.x = rect.width - 320
if (popupPosition.value.y > rect.height - 300) popupPosition.value.y = rect.height - 300 if (popupPosition.value.y > rect.height - 300) popupPosition.value.y = rect.height - 300
showPopup.value = true showPopup.value = true
} }
// 摄像头控制状态
// const isCameraFullscreen = ref(false)
// const isAudioMuted = ref(true)
const cameraVideo = ref(null) const cameraVideo = ref(null)
// 添加标注点到地图 // 添加标注点到地图
const addAnnotationsToMap = () => { const addAnnotationsToMap = () => {
if (!map) return 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)
})
} }
// 摄像头相关方法 // 摄像头相关方法
@@ -400,7 +613,7 @@ onUnmounted(() => {
width: 100%; width: 100%;
height: 800px; height: 800px;
border: 1px solid #ccc; border: 1px solid #ccc;
border-radius: 8px; /* border-radius: 8px; */
overflow: hidden; overflow: hidden;
} }
@@ -496,7 +709,7 @@ onUnmounted(() => {
position: absolute; position: absolute;
width: 400px; width: 400px;
background: white; background: white;
border-radius: 12px; /* border-radius: 12px; */
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
z-index: 2000; z-index: 2000;
animation: popupFadeIn 0.3s ease; animation: popupFadeIn 0.3s ease;
@@ -509,7 +722,7 @@ onUnmounted(() => {
padding: 15px 20px; padding: 15px 20px;
background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%); background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
color: white; color: white;
border-radius: 12px 12px 0 0; /* border-radius: 12px 12px 0 0; */
} }
.camera-status { .camera-status {
@@ -521,7 +734,7 @@ onUnmounted(() => {
.status-dot { .status-dot {
width: 8px; width: 8px;
height: 8px; height: 8px;
border-radius: 50%; /* border-radius: 50%; */
background: #f44336; background: #f44336;
} }
@@ -546,10 +759,10 @@ onUnmounted(() => {
} }
.video-container { .video-container {
width: 100%; width: auto;
height: 200px; height:auto;
background: #000; background: #000;
border-radius: 8px; /* border-radius: 8px; */
overflow: hidden; overflow: hidden;
margin-bottom: 15px; margin-bottom: 15px;
} }
@@ -608,7 +821,7 @@ onUnmounted(() => {
background: #2196F3; background: #2196F3;
color: white; color: white;
border: none; border: none;
border-radius: 4px; /* border-radius: 4px; */
cursor: pointer; cursor: pointer;
font-size: 12px; font-size: 12px;
transition: background 0.3s ease; transition: background 0.3s ease;
@@ -621,4 +834,351 @@ onUnmounted(() => {
.control-btn:active { .control-btn:active {
background: #1565C0; background: #1565C0;
} }
.marker-popup {
position: absolute;
z-index: 9999;
pointer-events: auto;
}
/* 底部固定弹窗样式 */
.marker-popup.bottom-fixed {
position: fixed;
bottom: 20px;
left: 20px;
right: 20px;
width: 50%;
height: 100px;
margin: 0 auto;
overflow: auto;
}
.popup-content {
position: relative;
background: white;
color: #333;
padding: 16px;
border-radius: 12px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.popup-arrow {
position: absolute;
top: -8px;
left: 50%;
transform: translateX(-50%);
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid white;
}
.popup-main {
display: flex;
flex-direction: row;
align-items: center;
margin-bottom: 12px;
}
.popup-left {
margin-right: 12px;
}
.popup-image {
width: 80px;
height: 80px;
border-radius: 8px;
background-color: #f0f0f0;
}
.popup-center {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
}
.marker-name {
font-weight: bold;
font-size: 18px;
color: #333;
margin-bottom: 6px;
display: block;
}
.marker-desc {
font-size: 14px;
color: #666;
display: block;
}
.popup-right {
margin-left: 12px;
}
.camera-info {
font-size: 16px;
color: #ff4444;
font-weight: bold;
white-space: nowrap;
}
/* 关闭按钮样式 */
.close-popup-btn {
position: absolute;
top: 12px;
right: 12px;
width: 28px;
height: 28px;
background: rgba(0, 0, 0, 0.05);
border: none;
border-radius: 50%;
font-size: 20px;
color: #999;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
padding: 0;
line-height: 1;
}
.close-popup-btn:hover {
background: rgba(0, 0, 0, 0.1);
color: #333;
transform: rotate(90deg);
}
.close-popup-btn:active {
background: rgba(0, 0, 0, 0.15);
}
.popup-bottom {
text-align: right;
}
.popup-button {
background-color: #1890ff;
color: white;
border: none;
border-radius: 6px;
padding: 10px 24px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
margin: 0;
}
.popup-button::after {
border: none;
}
/* 摄像头列表样式 */
.camera-list {
margin-top: 16px;
border-top: 1px solid #eee;
padding-top: 12px;
}
.camera-list h4 {
margin: 0 0 12px 0;
font-size: 14px;
color: #333;
font-weight: 600;
}
.camera-items {
display: flex;
flex-direction: column;
gap: 8px;
}
.camera-item {
display: flex;
align-items: center;
padding: 10px;
background: #f5f7fa;
border-radius: 6px;
cursor: pointer;
transition: all 0.3s ease;
}
.camera-item:hover {
background: #e8f4ff;
transform: translateX(4px);
}
.camera-icon {
font-size: 24px;
margin-right: 12px;
}
.camera-details {
flex: 1;
}
.camera-name {
font-size: 13px;
color: #333;
font-weight: 500;
margin-bottom: 4px;
}
.camera-status {
font-size: 11px;
padding: 2px 6px;
border-radius: 3px;
display: inline-block;
}
.camera-status.online {
background: #e6f7e6;
color: #52c41a;
}
.camera-status.offline {
background: #fff1f0;
color: #ff4d4f;
}
.play-icon {
font-size: 16px;
color: #1890ff;
margin-left: 8px;
}
/* 视频播放弹窗样式 */
.camera-video-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.8);
display: flex;
align-items: center;
justify-content: center;
z-index: 10000;
}
.video-container {
background: white;
border-radius: 12px;
padding: 20px;
max-width: 90%;
max-height: 90%;
}
.video-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.video-header h3 {
margin: 0;
font-size: 18px;
color: #333;
}
.close-video-btn {
background: none;
border: none;
font-size: 28px;
color: #999;
cursor: pointer;
padding: 0;
width: 30px;
height: 30px;
display: flex;
align-items: center;
justify-content: center;
transition: color 0.3s ease;
}
.close-video-btn:hover {
color: #333;
}
.video-player {
width: 100%;
max-width: 800px;
max-height: 600px;
border-radius: 8px;
background: #000;
}
.route-info-panel {
position: absolute;
top: 20px;
left: 20px;
background: white;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
z-index: 1000;
min-width: 280px;
overflow: hidden;
}
.route-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 16px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.route-header h3 {
margin: 0;
font-size: 16px;
font-weight: 600;
}
.route-header .close-btn {
background: rgba(255, 255, 255, 0.2);
border: none;
color: white;
width: 28px;
height: 28px;
border-radius: 50%;
font-size: 20px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.3s ease;
}
.route-header .close-btn:hover {
background: rgba(255, 255, 255, 0.3);
}
.route-content {
padding: 16px;
}
.route-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 0;
border-bottom: 1px solid #f0f0f0;
}
.route-item:last-child {
border-bottom: none;
}
.route-item .label {
color: #666;
font-size: 14px;
}
.route-item .value {
color: #333;
font-size: 14px;
font-weight: 600;
}
</style> </style>