活动介绍

如何让这段代码的最小高度随页面内容的增加而增加 .log{ position: absolute; top: 5%; left: 20%; border: 3px solid black; width: 1000px; padding-left: 50px; min-height: 1000px; border-radius: 5%; }

时间: 2024-02-10 13:14:31 浏览: 73
要让这段代码的最小高度随页面内容增加而增加,可以将`min-height`属性修改为`height`属性,并将其值设置为"auto",即将`min-height: 1000px;`修改为`height: auto;`,如下所示: ``` .log{ position: absolute; top: 5%; left: 20%; border: 3px solid black; width: 1000px; padding-left: 50px; height: auto; /* 将高度设置为自适应 */ border-radius: 5%; } ``` 这样,当页面内容增加时,该框架的最小高度就会自动增加以适应页面内容。
相关问题

将这段代码设置为根据页面大小自动调整高度 .log{ position: absolute; top: 5%; left: 20%; border: 3px solid black; width: 1000px; padding-left: 50px; min-height: 500px; border-radius: 5%; }

可以使用CSS3的calc()函数和vh单位来实现根据页面大小自动调整高度的效果。代码如下: ``` .log { position: absolute; top: 5%; left: 20%; border: 3px solid black; width: 1000px; padding-left: 50px; min-height: calc(100vh - 10%); border-radius: 5%; } ``` 其中,calc()函数用来计算高度值,100vh表示视口高度,10%表示顶部和底部的空白区域高度之和。这样就可以让日志框的高度自适应页面大小,同时保证顶部和底部有一定的间距。

.log{ position: absolute; top: 5%; left: 20%; border: 3px solid black; width: 1000px; padding-left: 50px; min-height: 1100px; border-radius: 5%; }如何用JS修改这串代码的min-height属性为随页面高度自动变化

您可以使用window.innerHeight属性获取浏览器窗口的高度,然后将其赋值给min-height属性。以下是示例代码: ```javascript let log = document.querySelector('.log'); log.style.minHeight = `${window.innerHeight}px`; window.addEventListener('resize', () => { log.style.minHeight = `${window.innerHeight}px`; }); ``` 这段代码将获取log元素,将其min-height属性设置为浏览器窗口的高度,并添加一个事件监听器,以便在窗口大小调整时更新min-height属性。
阅读全文

相关推荐

ul.head{ border-style: groove; position: fixed; top:0; width:99%; list-style-type: none; margin-top:0; padding-left: 0px; /*创建一个新的BFC*/ overflow: hidden; background:indianred; border-radius:8px;/*圆角边框*/ font-size:18px; } li a{ /* !*实现横向导航栏, display:inline;也可,如果你想链接到具有相同的大小,你必须使用浮动的方法*!*/ float:left; height:20px; text-align: center; color: white; background-color: darksalmon; padding: 12px 20px; text-decoration: none; } li a:hover{ background-color: coral; color: black; } body{ background-attachment: fixed; background-image: url(../resources/image/blue_pink.jpg); background-size:100%; } iframe{ height:300px; width:400px; float:right; } select{ font-size: 20px; color:olive; background-color:cornsilk; } div{ margin-top:60px; } input{font-size: 16px;} button { border-radius:5px;/*圆角边框*/ font-size: 18px; background-color: #4CAF50; color: white; cursor: pointer; transition: background-color 0.3s ease; } #pauseBtn{ position:absolute; bottom:17%; left:40%; } #startBtn{ position:absolute; bottom:59%; left:15%; } #increase-btn1 { position:absolute; left: 17%; bottom:9%; } #decrease-btn1 { position:absolute; left: 19%; bottom:9%; } #increase-btn2 { position:absolute; right: 19%; bottom:25%; } #decrease-btn2 { position:absolute; right: 17%; bottom:25%; } #speedRange{ position:absolute; bottom:17%; left:50%; } button:hover { background-color: #3e8e41; } #introduction{ margin-top: 20px; width:300px; border-style: groove; font-size: 14px; color:darkred; overflow: auto; min-height:300px; max-height:300px; } footer{ position:absolute; bottom:0; width:100%; height:30px; text-align: center; } #canvas{ /*width: 880px;*/ /*height: 440px;*/ width: 100%; height: 100%; /*margin: -210px auto;*/ /*border: 2px solid yellowgreen;*/ /*display: block;*/ overflow: scroll; } .container { height: 440px; width: 880px; margin: -225px auto; border: 2px solid yellowgreen; /*display: block;*/ box-sizing:border-box; overflow: scroll; } #log{ border:2px palegoldenrod; position:absolute; top:9%; right:0.5%; background-color:lightyellow; height: 430px; /* 设置固定高度 */ width: 310px; /* 设置固定宽度 */ font-size: 16px; /* 设置默认字体大小 */ resize: none; /* 其他样式属性 */ } .red-text { color: red; }

<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>扫码解锁视频</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: Arial, sans-serif; background: #000; color: #fff; height: 100vh; overflow: hidden; } .slider { display: flex; width: 400%; height: 100%; transition: transform 0.3s ease; } .slide { width: 100vw; height: 100vh; flex-shrink: 0; position: relative; overflow: hidden; background: #111; } video { width: 100%; height: 100%; object-fit: cover; } /* 未解锁提示文字 */ .lock-tip { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); color: #fff; background: rgba(0, 0, 0, 0.5); padding: 6px 12px; border-radius: 5px; font-size: 16px; display: none; z-index: 2; } .hint { position: absolute; bottom: 40px; width: 100%; text-align: center; color: rgba(255,255,255,0.8); font-size: 14px; z-index: 2; } /* 扫码解锁按钮 */ #scanButton { position: fixed; top: 20px; right: 20px; z-index: 9999; background: #fff; color: #000; border: none; padding: 10px 15px; border-radius: 5px; font-size: 14px; cursor: pointer; } /* 分页指示器 */ .pagination { position: absolute; bottom: 10px; width: 100%; display: flex; justify-content: center; gap: 8px; } .dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.3); transition: background 0.3s; } .dot.active { background: #fff; } </style> </head> <body> <bu

<template> <Search @location-selected="handleLocationSelected" /> <LocationBar v-if="loaded" :update-interval="100" :use-dms-format="useDmsFormat" /> </template> <style> /* @import "/temp/css/divGraphic.css"; */ </style> <script setup lang="ts"> import { computed, onUnmounted, onMounted, reactive } from "vue"; import LocationBar from "./location-bar.vue"; import Search from "./search.vue"; import initMap from "./init"; import { ref } from "vue"; import { throttle } from 'lodash'; import { loadRipplePoints, createMultipleRippleCircles } from './circle.js'; import { $prototype } from "../../main.ts"; const miniMapContainer = ref<HTMLElement>(); let viewIndicator: Rectangle; // 视图指示器样式 const currentPosition = reactive({ longitude: 113.361538, latitude: 27.339318, }); // 株洲市范围常量 const ZHUZHOU_EXTENT = { west: 112.5, // 株洲市西边界 east: 114.5, // 株洲市东边界 south: 26.0, // 株洲市南边界 north: 28.0 // 株洲市北边界 }; const rippleEntities = ref<any[]>([]); // 存储波纹圆实体 const heightThreshold = 80000; // 高度阈值(米),高于此值隐藏波纹圆 const updateRippleVisibility = throttle(() => { if (!$prototype.$map || rippleEntities.value.length === 0) return; // 添加缺失的相机高度计算和显示判断 const cameraHeight = $prototype.$map.camera.positionCartographic.height; const shouldShow = cameraHeight > heightThreshold; rippleEntities.value.forEach(entity => { entity.show = shouldShow; }); }, 200); // 更新指示器位置 const updateIndicatorPosition = () => { if (!$prototype.$map) return; const camera = $prototype.$map.camera; const rect = camera.computeViewRectangle(); if (!rect) return; // 计算在株洲市范围内的相对位置 const center = Cesium.Rectangle.center(rect); const lon = Cesium.Math.toDegrees(center.longitude); const lat = Cesium.Math.toDegrees(center.latitude); const lonPercent = ((lon - ZHUZHOU_EXTENT.west) / (ZHUZHOU_EXTENT.east - ZHUZHOU_EXTENT.west)) * 100; const latPercent = 100 - ((lat - ZHUZHOU_EXTENT.south) / (ZHUZHOU_EXTENT.north - ZHUZHOU_EXTENT.south)) * 100; // 更新CSS指示器 indicatorStyle.value = { left: ${lonPercent}%, top: ${latPercent}%, display: "block" }; }; // 更新鹰眼地图 - 只更新指示器位置 const updateOverview = () => { if (!$prototype.$map || !overviewViewer.value) return; // 获取主地图的当前视图中心 const rectangle = $prototype.$map.camera.computeViewRectangle(); if (!rectangle) return; const center = Cesium.Rectangle.center(rectangle); currentPosition.longitude = Cesium.Math.toDegrees(center.longitude); currentPosition.latitude = Cesium.Math.toDegrees(center.latitude); // 更新指示器位置 updateIndicatorPosition(); }; const overviewViewer = ref(null); // 初始化鹰眼地图 - 使用株洲市影像 const initMiniMap = () => { Cesium.Ion.defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIxMDhlNDdmYy03NzFhLTQ1ZTQtOWQ3NS1lZDAzNDc3YjE4NDYiLCJpZCI6MzAxNzQyLCJpYXQiOjE3NDcwNTMyMDN9.eaez8rQxVbPv2LKEU0sMDclPWyHKhh1tR27Vg-_rQSM"; if (!miniMapContainer.value) return; // 创建株洲市专用影像提供器 const zhuzhouProvider = new Cesium.UrlTemplateImageryProvider({ url: "http://124.232.190.30:9000/proxy/pk1725866655224/map/zzzsyx_18/{z}/{x}/{y}.png", minimumLevel: 1, maximumLevel: 17, crs: "EPSG:3857", }); // 鹰眼地图初始化 - 使用株洲市影像 overviewViewer.value = new Cesium.Viewer(miniMapContainer.value, { sceneMode: Cesium.SceneMode.SCENE2D, baseLayerPicker: false, homeButton: false, timeline: false, navigationHelpButton: false, animation: false, scene3DOnly: true, selectionIndicator: false, infoBox: false, imageryProvider: zhuzhouProvider, // 使用株洲市影像 terrainProvider: window.Cesium.createWorldTerrain(), }); // 设置固定视野为株洲市范围 overviewViewer.value.camera.setView({ destination: Cesium.Rectangle.fromDegrees( ZHUZHOU_EXTENT.west, ZHUZHOU_EXTENT.south, ZHUZHOU_EXTENT.east, ZHUZHOU_EXTENT.north ) }); // 隐藏控件 var toolbar = overviewViewer.value.container.getElementsByClassName("cesium-viewer-toolbar")[0]; if (toolbar) toolbar.style.display = "none"; overviewViewer.value.cesiumWidget.creditContainer.style.display = "none"; }; // 初始化视图指示器 function initRectangle() { // 创建视图指示器(株洲市范围框) viewIndicator = overviewViewer.value.entities.add({ rectangle: { coordinates: new Cesium.CallbackProperty(() => { return Cesium.Rectangle.fromDegrees( ZHUZHOU_EXTENT.west, ZHUZHOU_EXTENT.south, ZHUZHOU_EXTENT.east, ZHUZHOU_EXTENT.north ); }, false), material: Cesium.Color.RED.withAlpha(0.3), outline: true, outlineColor: Cesium.Color.RED, outlineWidth: 2, }, }); } // 指示器样式计算 const indicatorStyle = computed(() => { return {}; // 由updateIndicatorPosition直接设置 }); const loaded = ref(false); const useDmsFormat = ref(false); function addDemoGraphics() { const chinaBoundary = $prototype.$map.dataSources.add( Cesium.GeoJsonDataSource.load("/shp_zz.geojson", { stroke: Cesium.Color.WHITE, fill: false, clampToGround: true, describe: null, }) ); chinaBoundary.then((dataSource) => { const entities = dataSource.entities.values; for (let entity of entities) { if (entity.polyline) { entity.polyline.fill = false; } } }); } function flyToDes() { const center = Cesium.Cartesian3.fromDegrees(-98.0, 40.0); $prototype.$map.camera.flyTo({ destination: new Cesium.Cartesian3( -2432812.6687511606, 5559483.804371395, 2832009.419525571 ), orientation: { heading: 6.283185307179421, pitch: -1.0472145569408116, roll: 6.2831853071795205, }, complete: function () {}, }); } // 监听主地图相机变化 const setupCameraListener = () => { $prototype.$map.camera.changed.addEventListener(updateOverview); }; // 鹰眼地图点击处理 const handleMiniMapClick = (event: MouseEvent) => { if (!miniMapContainer.value || !overviewViewer.value) return; const rect = miniMapContainer.value.getBoundingClientRect(); const x = event.clientX - rect.left; const y = event.clientY - rect.top; // 计算在固定范围内的相对位置 const xPercent = (x / rect.width) * 100; const yPercent = (y / rect.height) * 100; // 转换为株洲市范围内的经纬度 const lon = ZHUZHOU_EXTENT.west + (xPercent / 100) * (ZHUZHOU_EXTENT.east - ZHUZHOU_EXTENT.west); const lat = ZHUZHOU_EXTENT.north - (yPercent / 100) * (ZHUZHOU_EXTENT.north - ZHUZHOU_EXTENT.south); // 主地图飞向点击位置 $prototype.$map.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(lon, lat, 1000000), }); }; function addImage() { var rightImageProvider = new Cesium.UrlTemplateImageryProvider({ name: "影像图", type: "xyz", layer: "vec_d", url: "http://124.232.190.30:9000/proxy/pk1725866655224/map/zzzsyx_18/{z}/{x}/{y}.png", minimumLevel: 1, maximumLevel: 17, crs: "EPSG:3857", }); $prototype.$map.imageryLayers.addImageryProvider(rightImageProvider); rightImageProvider.splitDirection = Cesium.SplitDirection.right; } onMounted(() => { initMap(); addImage(); loaded.value = true; addDemoGraphics(); flyToDes(); initMiniMap(); setupCameraListener(); setTimeout(function () { initRectangle(); }, 2000); (async () => { try { const ripplePoints = await loadRipplePoints(); rippleEntities.value = createMultipleRippleCircles( $prototype.$map, ripplePoints ); $prototype.$map.camera.changed.addEventListener(updateRippleVisibility); updateRippleVisibility(); } catch (error) { console.error('加载波纹圆失败:', error); } })(); }); let currentMarker: any = null; const createMarker = (location: { lng: number; lat: number; name: string }) => { if (currentMarker) { $prototype.$map.entities.remove(currentMarker); } currentMarker = $prototype.$map.entities.add({ position: Cesium.Cartesian3.fromDegrees( location.lng, location.lat, 50 ), point: { pixelSize: 200, color: Cesium.Color.RED, outlineColor: Cesium.Color.WHITE, outlineWidth: 2, heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND, }, label: { text: location.name, font: "40px sans-serif", fillColor: Cesium.Color.WHITE, outlineColor: Cesium.Color.BLACK, outlineWidth: 1, verticalOrigin: Cesium.VerticalOrigin.BOTTOM, pixelOffset: new Cesium.Cartesian2(0, -20), heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND, distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 10000), }, description: ${location.name} 经度:${location.lng.toFixed(6)} 纬度:${location.lat.toFixed(6)} , }); return currentMarker; }; const handleLocationSelected = (location: { lng: number; lat: number; name: string; }) => { if (!$prototype.$map) return; const destination = Cesium.Cartesian3.fromDegrees( location.lng, location.lat, 200 ); $prototype.$map.camera.flyTo({ destination, orientation: { heading: Cesium.Math.toRadians(0), pitch: Cesium.Math.toRadians(-45), roll: 0, }, duration: 2, complete: () => { createMarker(location); }, }); }; onUnmounted(() => { if ($prototype.$map) { $prototype.$map.destroy(); $prototype.$map = null; } if ($prototype.$map) { $prototype.$map.camera.changed.removeEventListener(updateRippleVisibility); } console.log("组件销毁"); }); const emit = defineEmits(["onload", "onclick"]); const initMars3d = async (option: any) => { emit("onclick", true); emit("onload", $prototype.$map); }; </script> <style lang="less"> /**cesium 工具按钮栏*/ .cesium-viewer-toolbar { top: auto !important; bottom: 35px !important; left: 12px !important; right: auto !important; } .cesium-toolbar-button img { height: 100%; } .cesium-viewer-toolbar > .cesium-toolbar-button, .cesium-navigationHelpButton-wrapper, .cesium-viewer-geocoderContainer { margin-bottom: 5px; float: left; clear: both; text-align: center; } .cesium-button { background-color: rgba(23, 49, 71, 0.8); color: #e6e6e6; fill: #e6e6e6; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); line-height: 32px; } .cesium-button:hover { background: #3ea6ff; } /**cesium 底图切换面板*/ .cesium-baseLayerPicker-dropDown { bottom: 0; left: 40px; max-height: 700px; margin-bottom: 5px; background-color: rgba(23, 49, 71, 0.8); } /**cesium 帮助面板*/ .cesium-navigation-help { top: auto; bottom: 0; left: 40px; transform-origin: left bottom; background: none; background-color: rgba(23, 49, 71, 0.8); .cesium-navigation-help-instructions { background: none; } .cesium-navigation-button { background: none; } .cesium-navigation-button-selected, .cesium-navigation-button-unselected:hover { background: rgba(0, 138, 255, 0.2); } } /**cesium 二维三维切换*/ .cesium-sceneModePicker-wrapper { width: auto; } .cesium-sceneModePicker-wrapper .cesium-sceneModePicker-dropDown-icon { float: right; margin: 0 3px; } /**cesium POI查询输入框*/ .cesium-viewer-geocoderContainer .search-results { left: 0; right: 40px; width: auto; z-index: 9999; } .cesium-geocoder-searchButton { background-color: rgba(23, 49, 71, 0.8); } .cesium-viewer-geocoderContainer .cesium-geocoder-input { background-color: rgba(63, 72, 84, 0.7); } .cesium-viewer-geocoderContainer .cesium-geocoder-input:focus { background-color: rgba(63, 72, 84, 0.9); } .cesium-viewer-geocoderContainer .search-results { background-color: rgba(23, 49, 71, 0.8); } /**cesium info信息框*/ .cesium-infoBox { top: 50px; background-color: rgba(23, 49, 71, 0.8); } .cesium-infoBox-title { background-color: rgba(23, 49, 71, 0.8); } /**cesium 任务栏的FPS信息*/ .cesium-performanceDisplay-defaultContainer { top: auto; bottom: 35px; right: 50px; } .cesium-performanceDisplay-ms, .cesium-performanceDisplay-fps { color: #fff; } /**cesium tileset调试信息面板*/ .cesium-viewer-cesiumInspectorContainer { top: 10px; left: 10px; right: auto; } .cesium-cesiumInspector { background-color: rgba(23, 49, 71, 0.8); } /**覆盖mars3d内部控件的颜色等样式*/ .mars3d-compass .mars3d-compass-outer { fill: rgba(23, 49, 71, 0.8); } .mars3d-contextmenu-ul, .mars3d-sub-menu { background-color: rgba(23, 49, 71, 0.8); > li > a:hover, > li > a:focus, > li > .active { background-color: #3ea6ff; } > .active > a, > .active > a:hover, > .active > a:focus { background-color: #3ea6ff; } } /* Popup样式*/ .mars3d-popup-color { color: #ffffff; } .mars3d-popup-background { background: rgba(23, 49, 71, 0.8); } .mars3d-popup-content { margin: 15px; } .mars3d-template-content label { padding-right: 6px; } .mars3d-template-titile { border-bottom: 1px solid #3ea6ff; } .mars3d-template-titile a { font-size: 16px; } .mars3d-tooltip { background: rgba(23, 49, 71, 0.8); border: 1px solid rgba(23, 49, 71, 0.8); } .mars3d-popup-btn-custom { padding: 3px 10px; border: 1px solid #209ffd; background: #209ffd1c; } .mars-dialog .mars-dialog__content { height: 100%; width: 100%; overflow: auto; padding: 5px; } .image { border: solid 2px #fff; } .content { height: 90%; padding-top: 10px; overflow-x: auto; overflow-y: auto; } .content-text { padding: 0 10px; text-indent: 30px; font-size: 17px; } .details-video { width: 100%; height: 760px; background-color: #000; } :where(.css-lt97qq9).ant-space { display: inline-flex; } :where(.css-lt97qq9).ant-space-align-center { align-items: center; } :where(.css-lt97qq9).ant-image .ant-image-mask { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; background: rgba(0, 0, 0, 0.5); cursor: pointer; opacity: 0; transition: opacity 0.3s; } :where(.css-lt97qq9).ant-image .ant-image-mask .ant-image-mask-info { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 4px; } :where(.css-1t97qq9)[class^="ant-image"] [class^="ant-image"], :where(.css-1t97qq9)[class*=" ant-image"] [class^="ant-image"], :where(.css-1t97qq9)[class^="ant-image"] [class*=" ant-image"], :where(.css-1t97qq9)[class*=" ant-image"] [class*=" ant-image"] { box-sizing: border-box; } :where(.css-lt97qq9).ant-image .ant-image-img { width: 100%; height: auto; vertical-align: middle; } </style> <style scoped> .mini-map-container { position: relative; width: 100%; height: 100%; } .main-viewer { width: 100%; height: 100%; } .mini-map { position: absolute; right: 3vw; bottom: 6vh; width: 12vw; height: 17vh; border: 2px solid #fff; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); z-index: 999; cursor: pointer; overflow: hidden; } .location-indicator { position: absolute; width: 14px; height: 14px; background: #ff3e3e; border: 2px solid white; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 15px rgba(255, 62, 62, 1); z-index: 100; } .view-rectangle { position: absolute; border: 2px solid #00f2fe; z-index: 99; pointer-events: none; box-shadow: 0 0 20px rgba(0, 242, 254, 0.7); } /* 相机聚焦样式 - 四个角折角 */ .corner { position: absolute; width: 25px; height: 25px; z-index: 100; pointer-events: none; } .corner::before, .corner::after { content: ""; position: absolute; background: #00f2fe; box-shadow: 0 0 10px rgba(0, 242, 254, 0.8); } .corner-top-left { top: -2px; left: -2px; } .corner-top-left::before { top: 0; left: 0; width: 15px; height: 3px; } .corner-top-left::after { top: 0; left: 0; width: 3px; height: 15px; } .corner-top-right { top: -2px; right: -2px; } .corner-top-right::before { top: 0; right: 0; width: 15px; height: 3px; } .corner-top-right::after { top: 0; right: 0; width: 3px; height: 15px; } .corner-bottom-left { bottom: -2px; left: -2px; } .corner-bottom-left::before { bottom: 0; left: 0; width: 15px; height: 3px; } .corner-bottom-left::after { bottom: 0; left: 0; width: 3px; height: 15px; } .corner-bottom-right { bottom: -2px; right: -2px; } .corner-bottom-right::before { bottom: 0; right: 0; width: 15px; height: 3px; } .corner-bottom-right::after { bottom: 0; right: 0; width: 3px; height: 15px; } .camera-icon { position: absolute; top: 10px; right: 10px; color: #00f2fe; font-size: 24px; z-index: 100; text-shadow: 0 0 10px rgba(0, 242, 254, 0.8); } .focus-effect { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 98; border: 2px solid rgba(0, 242, 254, 0.2); border-radius: 5px; box-shadow: inset 0 0 30px rgba(0, 242, 254, 0.1); } .pulse { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 10px; height: 10px; border-radius: 50%; background: rgba(0, 242, 254, 0.7); box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.7); animation: pulse 2s infinite; } ::v-deep.cesium-viewer-toolbar { display: none; } </style> 如上代码,但是效果图中鹰眼地图加载了株洲遥感影像,但是鹰眼地图中其他部分就没了,呈现为全蓝色,而且红点也没有,不会随主地图变化红点,基于以上问题告诉我原因并修改代码

<template> 坐标系: <el-radio-group v-model="coordinateSystem" size="small"> <el-radio-button label="gcj02">高德/火星坐标</el-radio-button> <el-radio-button label="bd09">百度坐标</el-radio-button> </el-radio-group> <Search @location-selected="handleLocationSelected" /> <LocationBar v-if="loaded" :update-interval="100" :use-dms-format="useDmsFormat" /> </template> <style> /* 原有样式完全不变 */ </style> <script setup lang="ts"> // 原有导入 + 新增坐标转换工具类导入 import { computed, onUnmounted, onMounted, reactive, ref } from "vue"; import LocationBar from "./location-bar.vue"; import Search from "./search.vue"; import initMap from "./init"; import { throttle } from "lodash"; import { loadRipplePoints, createMultipleRippleCircles } from "./circle.js"; import { $ prototype } from "../../main.ts"; import markerImage from "@/assets/images/building.png"; import { imageDark } from "naive-ui/es/image/styles"; // 新增:导入坐标转换工具类 import { CoordinateTransformer } from "./coordinate-transformer"; // 修复类型定义 type Rectangle = any; // 原有状态 + 新增坐标系选择状态 const miniMapContainer = ref<HTMLElement>(); let viewIndicator: Rectangle; const currentPosition = reactive({ longitude: 113.361538, latitude: 27.339318, }); const ZHUZHOU_EXTENT = { west: 112.5, east: 114.5, south: 26.0, north: 28.0, }; const rippleEntities = ref<any[]>([]); const heightThreshold = 80000; const indicatorStyle = ref({ left: "50%", top: "50%", display: "block", }); const loaded = ref(false); const useDmsFormat = ref(false); const overviewViewer = ref(null); let currentMarker: any = null; // 新增:坐标系选择状态(默认高德GCJ-02) const coordinateSystem = ref("gcj02"); // 'gcj02' | 'bd09' // 原有方法完全不变(波纹可见性更新) const updateRippleVisibility = throttle(() => { if (!$ prototype.$ map || rippleEntities.value.length === 0) return; let shouldShow = false; const cartographic = $ prototype.$ map.camera.positionCartographic; if (cartographic) { const cameraHeight = cartographic.height; shouldShow = cameraHeight > heightThreshold; } rippleEntities.value.forEach((entity) => { entity.show = shouldShow; }); }, 200); // 原有方法完全不变(指示器位置更新) const updateIndicatorPosition = () => { if (!$ prototype.$ map) return; const camera = $ prototype.$ map.camera; const rect = camera.computeViewRectangle(); if (!rect) return; const center = Cesium.Rectangle.center(rect); const lon = Cesium.Math.toDegrees(center.longitude); const lat = Cesium.Math.toDegrees(center.latitude); const constrainedLon = Math.max( ZHUZHOU_EXTENT.west, Math.min(ZHUZHOU_EXTENT.east, lon) ); const constrainedLat = Math.max( ZHUZHOU_EXTENT.south, Math.min(ZHUZHOU_EXTENT.north, lat) ); const lonPercent = ((constrainedLon - ZHUZHOU_EXTENT.west) / (ZHUZHOU_EXTENT.east - ZHUZHOU_EXTENT.west)) * 100; const latPercent = 100 - ((constrainedLat - ZHUZHOU_EXTENT.south) / (ZHUZHOU_EXTENT.north - ZHUZHOU_EXTENT.south)) * 100; indicatorStyle.value = { left: ${lonPercent}%, top: ${latPercent}%, display: "block", }; }; // 原有方法完全不变(鹰眼地图更新) const updateOverview = () => { if (!$ prototype.$ map || !overviewViewer.value) return; const rectangle = $ prototype.$ map.camera.computeViewRectangle(); if (!rectangle) return; updateIndicatorPosition(); }; // 原有方法完全不变(初始化鹰眼地图) const initMiniMap = () => { Cesium.Ion.defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIxMDhlNDdmYy03NzFhLTQ1ZTQtOWQ3NS1lZDAzNDc3YjE4NDYiLCJpZCI6MzAxNzQyLCJpYXQiOjE3NDcwNTMyMDN9.eaez8rQxVbPv2LKEU0sMDclPWyHKhh1tR27Vg-_rQSM"; if (!miniMapContainer.value) return; const worldProvider = new Cesium.UrlTemplateImageryProvider({ url: "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}", minimumLevel: 0, maximumLevel: 19, tilingScheme: new Cesium.WebMercatorTilingScheme(), }); const zhuzhouProvider = new Cesium.UrlTemplateImageryProvider({ url: "http://124.232.190.30:9000/proxy/pk1725866655224/map/zzzsyx_18/{z}/{x}/{y}.png", minimumLevel: 1, maximumLevel: 17, tilingScheme: new Cesium.WebMercatorTilingScheme(), }); overviewViewer.value = new Cesium.Viewer(miniMapContainer.value, { sceneMode: Cesium.SceneMode.SCENE2D, baseLayerPicker: false, homeButton: false, timeline: false, navigationHelpButton: false, animation: false, scene3DOnly: true, selectionIndicator: false, infoBox: false, imageryProvider: worldProvider, terrainProvider: undefined, mapProjection: new Cesium.WebMercatorProjection(), skyBox: false, skyAtmosphere: false, }); const zhuzhouLayer = overviewViewer.value.imageryLayers.addImageryProvider( zhuzhouProvider ); overviewViewer.value.camera.setView({ destination: Cesium.Rectangle.fromDegrees( ZHUZHOU_EXTENT.west, ZHUZHOU_EXTENT.south, ZHUZHOU_EXTENT.east, ZHUZHOU_EXTENT.north ), }); const toolbar = overviewViewer.value.container.getElementsByClassName( "cesium-viewer-toolbar" )[0]; if (toolbar) toolbar.style.display = "none"; overviewViewer.value.cesiumWidget.creditContainer.style.display = "none"; initRectangle(); }; // 原有方法完全不变(初始化视图指示器) function initRectangle() { viewIndicator = overviewViewer.value.entities.add({ rectangle: { coordinates: Cesium.Rectangle.fromDegrees( ZHUZHOU_EXTENT.west, ZHUZHOU_EXTENT.south, ZHUZHOU_EXTENT.east, ZHUZHOU_EXTENT.north ), material: Cesium.Color.RED.withAlpha(0.3), outline: true, outlineColor: Cesium.Color.RED, outlineWidth: 2, }, }); } // 原有方法完全不变(添加演示图形) function addDemoGraphics() { const chinaBoundary = $ prototype.$ map.dataSources.add( Cesium.GeoJsonDataSource.load("/shp_zz.geojson", { stroke: Cesium.Color.WHITE, fill: false, clampToGround: true, describe: null, }) ); chinaBoundary.then((dataSource) => { const entities = dataSource.entities.values; for (let entity of entities) { if (entity.polyline) { entity.polyline.fill = false; } } }); } // 原有方法完全不变(飞行到默认位置) function flyToDes() { const center = Cesium.Cartesian3.fromDegrees(-98.0, 40.0); $ prototype.$ map.camera.flyTo({ destination: new Cesium.Cartesian3( -2432812.6687511606, 5559483.804371395, 2832009.419525571 ), orientation: { heading: 6.283185307179421, pitch: -1.0472145569408116, roll: 6.2831853071795205, }, complete: function () {}, }); } // 原有方法完全不变(监听相机变化) const setupCameraListener = () => { $ prototype.$ map.camera.changed.addEventListener(updateOverview); }; // 原有方法完全不变(鹰眼地图点击处理) const handleMiniMapClick = (event: MouseEvent) => { if (!miniMapContainer.value || !overviewViewer.value) return; const rect = miniMapContainer.value.getBoundingClientRect(); const x = event.clientX - rect.left; const y = event.clientY - rect.top; const xPercent = (x / rect.width) * 100; const yPercent = (y / rect.height) * 100; const lon = ZHUZHOU_EXTENT.west + (xPercent / 100) * (ZHUZHOU_EXTENT.east - ZHUZHOU_EXTENT.west); const lat = ZHUZHOU_EXTENT.north - (yPercent / 100) * (ZHUZHOU_EXTENT.north - ZHUZHOU_EXTENT.south); $ prototype.$ map.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(lon, lat, 1000000), }); }; // 原有生命周期方法完全不变 onMounted(() => { initMap(); loaded.value = true; addDemoGraphics(); flyToDes(); setTimeout(() => { initMiniMap(); setupCameraListener(); updateOverview(); }, 1000); (async () => { try { const ripplePoints = await loadRipplePoints(); rippleEntities.value = createMultipleRippleCircles($ prototype.$ map, ripplePoints); $ prototype.$ map.camera.changed.addEventListener(updateRippleVisibility); updateRippleVisibility(); } catch (error) { console.error("加载波纹圆失败:", error); } })(); }); // 原有方法完全不变(创建标记) const createMarker = (location: { lng: number; lat: number; name: string }) => { if (currentMarker) { $ prototype.$ map.entities.remove(currentMarker); } console.log("标记图片加载状态:", markerImage); console.log("创建标记位置:", location); currentMarker = $ prototype.$ map.entities.add({ position: Cesium.Cartesian3.fromDegrees(location.lng, location.lat, 10), label: { text: location.name + "(标记位置)", font: "18px sans-serif", fillColor: Cesium.Color.YELLOW, outlineColor: Cesium.Color.BLACK, outlineWidth: 2, verticalOrigin: Cesium.VerticalOrigin.TOP, pixelOffset: new Cesium.Cartesian2(0, 40), heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND, show: true, }, point: { pixelSize: 15, color: Cesium.Color.RED, outlineColor: Cesium.Color.WHITE, outlineWidth: 3, heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND, show: true, }, }); console.log("标记实体已添加:", currentMarker); $ prototype.$ map.scene.requestRender(); return currentMarker; }; // 核心修改:使用工具类实现动态坐标系转换 const handleLocationSelected = (location: { lng: number; lat: number; name: string }) => { if (!$ prototype.$ map) return; // 根据选择的坐标系进行转换 let wgsLocation; if (coordinateSystem.value === "gcj02") { // 高德/火星坐标转WGS84 wgsLocation = CoordinateTransformer.gcj02ToWgs84(location.lng, location.lat); } else { // 百度坐标转WGS84 wgsLocation = CoordinateTransformer.bd09ToWgs84(location.lng, location.lat); } console.log(转换前(${coordinateSystem.value})坐标:, location.lng, location.lat); console.log("转换后(WGS84)坐标:", wgsLocation.lng, wgsLocation.lat); // 使用转换后的坐标执行原有逻辑 const destination = Cesium.Cartesian3.fromDegrees( wgsLocation.lng, wgsLocation.lat, 2000 ); $ prototype.$ map.camera.flyTo({ destination, orientation: { heading: Cesium.Math.toRadians(0), pitch: Cesium.Math.toRadians(-45), roll: 0, }, duration: 2, complete: () => { createMarker({ ...location, ...wgsLocation }); }, }); }; // 原有方法完全不变(组件销毁清理) onUnmounted(() => { if ($ prototype.$ map) { $ prototype.$ map.destroy(); $ prototype.$ map = null; } if ($ prototype.$ map) { $ prototype.$ map.camera.changed.removeEventListener(updateRippleVisibility); } console.log("组件销毁"); }); const emit = defineEmits(["onload", "onclick"]); const initMars3d = async (option: any) => { emit("onclick", true); emit("onload", $ prototype.$ map); }; </script> <style lang="less"> /**cesium 工具按钮栏*/ .cesium-viewer-toolbar { top: auto !important; bottom: 35px !important; left: 12px !important; right: auto !important; } .cesium-toolbar-button img { height: 100%; } .cesium-viewer-toolbar > .cesium-toolbar-button, .cesium-navigationHelpButton-wrapper, .cesium-viewer-geocoderContainer { margin-bottom: 5px; float: left; clear: both; text-align: center; } .cesium-button { background-color: rgba(23, 49, 71, 0.8); color: #e6e6e6; fill: #e6e6e6; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); line-height: 32px; } .cesium-button:hover { background: #3ea6ff; } /**cesium 底图切换面板*/ .cesium-baseLayerPicker-dropDown { bottom: 0; left: 40px; max-height: 700px; margin-bottom: 5px; background-color: rgba(23, 49, 71, 0.8); } /**cesium 帮助面板*/ .cesium-navigation-help { top: auto; bottom: 0; left: 40px; transform-origin: left bottom; background: none; background-color: rgba(23, 49, 71, 0.8); .cesium-navigation-help-instructions { background: none; } .cesium-navigation-button { background: none; } .cesium-navigation-button-selected, .cesium-navigation-button-unselected:hover { background: rgba(0, 138, 255, 0.2); } } /**cesium 二维三维切换*/ .cesium-sceneModePicker-wrapper { width: auto; } .cesium-sceneModePicker-wrapper .cesium-sceneModePicker-dropDown-icon { float: right; margin: 0 3px; } /**cesium POI查询输入框*/ .cesium-viewer-geocoderContainer .search-results { left: 0; right: 40px; width: auto; z-index: 9999; } .cesium-geocoder-searchButton { background-color: rgba(23, 49, 71, 0.8); } .cesium-viewer-geocoderContainer .cesium-geocoder-input { background-color: rgba(63, 72, 84, 0.7); } .cesium-viewer-geocoderContainer .cesium-geocoder-input:focus { background-color: rgba(63, 72, 84, 0.9); } .cesium-viewer-geocoderContainer .search-results { background-color: rgba(23, 49, 71, 0.8); } /**cesium info信息框*/ .cesium-infoBox { top: 50px; background-color: rgba(23, 49, 71, 0.8); } .cesium-infoBox-title { background-color: rgba(23, 49, 71, 0.8); } /**cesium 任务栏的FPS信息*/ .cesium-performanceDisplay-defaultContainer { top: auto; bottom: 35px; right: 50px; } .cesium-performanceDisplay-ms, .cesium-performanceDisplay-fps { color: #fff; } /**cesium tileset调试信息面板*/ .cesium-viewer-cesiumInspectorContainer { top: 10px; left: 10px; right: auto; } .cesium-cesiumInspector { background-color: rgba(23, 49, 71, 0.8); } /**覆盖mars3d内部控件的颜色等样式*/ .mars3d-compass .mars3d-compass-outer { fill: rgba(23, 49, 71, 0.8); } .mars3d-contextmenu-ul, .mars3d-sub-menu { background-color: rgba(23, 49, 71, 0.8); > li > a:hover, > li > a:focus, > li > .active { background-color: #3ea6ff; } > .active > a, > .active > a:hover, > .active > a:focus { background-color: #3ea6ff; } } /* Popup样式*/ .mars3d-popup-color { color: #ffffff; } .mars3d-popup-background { background: rgba(23, 49, 71, 0.8); } .mars3d-popup-content { margin: 15px; } .mars3d-template-content label { padding-right: 6px; } .mars3d-template-titile { border-bottom: 1px solid #3ea6ff; } .mars3d-template-titile a { font-size: 16px; } .mars3d-tooltip { background: rgba(23, 49, 71, 0.8); border: 1px solid rgba(23, 49, 71, 0.8); } .mars3d-popup-btn-custom { padding: 3px 10px; border: 1px solid #209ffd; background: #209ffd1c; } .mars-dialog .mars-dialog__content { height: 100%; width: 100%; overflow: auto; padding: 5px; } .image { border: solid 2px #fff; } .content { height: 90%; padding-top: 10px; overflow-x: auto; overflow-y: auto; } .content-text { padding: 0 10px; text-indent: 30px; font-size: 17px; } .details-video { width: 100%; height: 760px; background-color: #000; } :where(.css-lt97qq9).ant-space { display: inline-flex; } :where(.css-lt97qq9).ant-space-align-center { align-items: center; } :where(.css-lt97qq9).ant-image .ant-image-mask { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; background: rgba(0, 0, 0, 0.5); cursor: pointer; opacity: 0; transition: opacity 0.3s; } :where(.css-lt97qq9).ant-image .ant-image-mask .ant-image-mask-info { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 4px; } :where(.css-1t97qq9)[class^="ant-image"] [class^="ant-image"], :where(.css-1t97qq9)[class*=" ant-image"] [class^="ant-image"], :where(.css-1t97qq9)[class^="ant-image"] [class*=" ant-image"], :where(.css-1t97qq9)[class*=" ant-image"] [class*=" ant-image"] { box-sizing: border-box; } :where(.css-lt97qq9).ant-image .ant-image-img { width: 100%; height: auto; vertical-align: middle; } </style> <style scoped> .mini-map-container { position: relative; width: 100%; height: 100%; } .main-viewer { width: 100%; height: 100%; } .mini-map { position: absolute; right: 3vw; bottom: 6vh; width: 12vw; height: 17vh; border: 2px solid #fff; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); z-index: 999; cursor: pointer; overflow: hidden; } .location-indicator { position: absolute; width: 19px; height: 19px; transform: translate(-50%, -50%); z-index: 100; border: 2px solid red; border-radius: 2px; } /* 原十字准星伪元素保持不变 */ .location-indicator::before, .location-indicator::after { content: ''; position: absolute; background-color: red; top: 50%; left: 50%; transform: translate(-50%, -50%); } .location-indicator::before { width: 12px; height: 2px; } .location-indicator::after { width: 2px; height: 12px; } /* 新增四条准星延伸线 */ .ext-line { position: absolute; background-color: red; } /* 顶部延伸线 - 从矩形边框向上延伸 */ .ext-line-top { top: -5px; left: 50%; transform: translateX(-50%); width: 2px; height: 5px; } /* 右侧延伸线 - 从矩形边框向右延伸 */ .ext-line-right { top: 50%; right: -5px; transform: translateY(-50%); width: 5px; height: 2px; } /* 底部延伸线 - 从矩形边框向下延伸 */ .ext-line-bottom { bottom: -5px; left: 50%; transform: translateX(-50%); width: 2px; height: 5px; } /* 左侧延伸线 - 从矩形边框向左延伸 */ .ext-line-left { top: 50%; left: -5px; transform: translateY(-50%); width: 5px; height: 2px; } .view-rectangle { position: absolute; border: 2px solid #00f2fe; z-index: 99; pointer-events: none; box-shadow: 0 0 20px rgba(0, 242, 254, 0.7); } /* 相机聚焦样式 - 四个角折角 */ .corner { position: absolute; width: 25px; height: 25px; z-index: 100; pointer-events: none; } .corner::before, .corner::after { content: ""; position: absolute; background: #00f2fe; box-shadow: 0 0 10px rgba(0, 242, 254, 0.8); } .corner-top-left { top: -2px; left: -2px; } .corner-top-left::before { top: 0; left: 0; width: 15px; height: 3px; } .corner-top-left::after { top: 0; left: 0; width: 3px; height: 15px; } .corner-top-right { top: -2px; right: -2px; } .corner-top-right::before { top: 0; right: 0; width: 15px; height: 3px; } .corner-top-right::after { top: 0; right: 0; width: 3px; height: 15px; } .corner-bottom-left { bottom: -2px; left: -2px; } .corner-bottom-left::before { bottom: 0; left: 0; width: 15px; height: 3px; } .corner-bottom-left::after { bottom: 0; left: 0; width: 3px; height: 15px; } .corner-bottom-right { bottom: -2px; right: -2px; } .corner-bottom-right::before { bottom: 0; right: 0; width: 15px; height: 3px; } .corner-bottom-right::after { bottom: 0; right: 0; width: 3px; height: 15px; } .camera-icon { position: absolute; top: 10px; right: 10px; color: #00f2fe; font-size: 24px; z-index: 100; text-shadow: 0 0 10px rgba(0, 242, 254, 0.8); } .focus-effect { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 98; border: 2px solid rgba(0, 242, 254, 0.2); border-radius: 5px; box-shadow: inset 0 0 30px rgba(0, 242, 254, 0.1); } .pulse { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 10px; height: 10px; border-radius: 50%; background: rgba(0, 242, 254, 0.7); box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.7); animation: pulse 2s infinite; } ::v-deep.cesium-viewer-toolbar { display: none; } </style> 检查live-map.vue代码,其中的鹰眼地图部分代码好像存在问题如下:鹰眼联动有问题,鹰眼图不用操作,基于此你帮我检查修改一下,尽可能不更改其他任何无关代码,减少对vue文件的修改

<template> <view class="wapper"> <image class="bg-image" src="/https/wenku.csdn.net/static/home/bus/bg-image.png" mode="widthFix" style="width: 100%;" /> <view class="custom-navbar" :style="{ paddingTop: statusBarHeight + 'px' }"> <view class="navbar-content"> <view class="back-btn" @click="handleBack"> <image src="/https/wenku.csdn.net/static/home/bus/back-icon.png" mode="aspectFit" style="width: 48rpx;height: 48rpx;" /> </view> <text class="title">{{busLineBase.name}}</text> </view> </view> <view class="wapper-content" :style="{ paddingTop: statusBarHeight +50 + 'px' }"> <view class="line_info"> <view class="site"> <text class="from">{{busLineBase.startSn}}</text> <view class="arrow"> <text class="to">{{busLineBase.endSn}}</text> </view> </view> <view class="tit"> <view class="time_s"> <text class="time-text">{{busLineBase.firstTime}}</text> </view> <view class="time_e"> <text class="time-text">{{busLineBase.lastTime}}</text> </view> <text class="price">票价: {{busLineBase.price}}</text> </view> </view> <view class="distance-class"> <view class="station"> <view class="station-title"> <view class="station-name">候车站</view> <view class="station-content"> <view class="active">{{stationName}}</view> <view class="underline"></view> </view> </view> </view> <view class="distance" v-if="state==0 && travelOrder!=0"> <view class="time"> <text class="time_title">{{Math.ceil(travelTime/60)}}分钟</text> </view> <text class="arr">{{travelOrder}}站/ <text v-if="travelDistance<1000">{{numFilter(travelDistance)}}m</text> <text v-else>{{numFilter(travelDistance/1000)}}km</text> </text> </view> <view class="distance" v-else-if="state==0 && travelOrder==0 && isArrive==1"> <view class="time"> <view class="bus-arr">已到站</view> </view> </view> <view class="distance" v-else-if="state==0 &&isArrive==0"> <view class="time"> <view class="bus-coming">即将到站 {{travelDistance}}m</view> </view> </view> <view class="distance" v-else-if="state==-1"> <view class="time"> <view class="none">等待发车</view> </view> </view> <view class="distance" v-else> <view class="time"> <view class="none">暂无车辆信息</view> </view> </view> </view> </view> <view class="site_list"> <scroll-view class="wapper_sitelist" scroll-x="true" scroll-with-animation :scroll-into-view="targetId"> <view class="road"> <view class='part' v-for="(item, index) in siteList" @click="showActive(index, item.sn)"> <view :id="'id'+item.sid" class='name'> <view> <view class="dot_p" :class="{'dot_p_show': ind === index}"></view> <view class='dot_r' v-if="index!=siteList.length-1"></view> </view> <view class='dot_d' :class="{'dot_d_show': ind === index}"></view> <view class='text' :class="{'text_show': ind === index}"> <view>{{index +1}}</view> <view class="text-dir"> {{item.sn}} </view> </view> </view> </view> </view> </scroll-view> </view> <view class="my-map"> 223123 <web-view ref="webview" :webview-styles="webviewStyles" :src="src" @onPostMessage="getMessage"></web-view> </view> </view> </template> <script> import { getRealTimeBusLine, getRealTimeBusLineStation } from '@/request/bus.js' export default { data() { return { src: '', timer: null, isArrive: 0, targetId: '', state: 0, stationName: '', travelDistance: 0, travelTime: 0, travelOrder: 0, ratio: '', ind: '', siteId: "", lineName: "二号线", siteName: "动漫园站", siteList: [], busLineBase: [], stateBus: [], time_s: '', time_e: '', from: '', busPosition: [0, 5, 11], to: '', isActive: false, lineId: '', siteNum: '0', haveBus: true, webviewStyles: { position: 'absolute', top: '850px', bottom: '30px', // zIndex: '999', marginTop: '850px', marginLeft: '20px', marginRight: '20px', marginBottom: '10px', height: '500px' } // 保留原有数据项... } }, onLoad(options) { // 获取路由参数 const { statusBarHeight } = uni.getSystemInfoSync() // const systemInfo = uni.getSystemInfoSync(); // this.ratio = (systemInfo.windowWidth / 750) / 0.5 console.log("options", options) this.statusBarHeight = statusBarHeight this.lineId = options.lineId this.lat = options.lat this.lng = options.lng this.lineName = options.lineName this.getLineDetail() if (this.timer) { clearInterval(this.timer); this.timer = null; } // this.timer = setInterval(() => { // console.log("30") // this.refresh() // }, 1000 * 30); this.init() }, methods: { init() { setTimeout(() => { this.src = '../../../../hybrid/html/map.html' }, 1000); }, handlePostMessage(res) { this.$refs.webview.evalJs(handleMessage()); }, getMessage(e) { uni.showModal({ content: "111", showCancel: false }) }, numFilter(value) { if (value != 0) { // 将数值转换为浮点数,并保留两位小数 let realVal = parseFloat(value).toFixed(2); return realVal; } }, async getLineDetail() { var res = await getRealTimeBusLine({ lineId: this.lineId, lat: this.lat, lng: this.lng }) if (res.code == 0) { console.log("1", res) this.siteList = res.data.busInfStop var ind = res.data.targetOrder this.ind = res.data.targetOrder - 1 this.stationName = this.siteList[ind - 1].sn this.state = res.data.state this.busLineBase = res.data.busLineBase this.targetOrder = res.data.targetOrder this.$nextTick(function() { this.targetId = 'id' + this.siteList[ind - 4].sid }); if (this.state == 0) { this.stateBus = res.data.stateBus var travelsList = this.stateBus.travels this.distance = this.findAllClosest(this.stateBus, this.targetOrder) if (this.distance.length != 0) { var travels = this.distance[0].travels this.travelDistance = travels[0].travelDistance this.travelOrder = travels[0].travelOrder this.travelTime = travels[0].travelTime this.siteList = this.processArrays(this.siteList, this.stateBus, 'order', 'state'); } } } }, async showActive(index, siteName) { this.ind = index this.stationName = siteName var res = await getRealTimeBusLineStation({ lineId: this.lineId, stationName: this.stationName }) if (res.code == 0) { this.siteList = res.data.busInfStop var ind = res.data.targetOrder this.stationName = this.siteList[ind - 1].sn this.state = res.data.state this.busLineBase = res.data.busLineBase this.ind = res.data.targetOrder - 1 this.targetOrder = res.data.targetOrder this.$nextTick(function() { this.targetId = 'id' + this.siteList[ind - 4].sid }); if (this.state == 0) { this.stateBus = res.data.stateBus var travelsList = this.stateBus.travels this.distance = this.findAllClosest(this.stateBus, this.targetOrder) if (this.distance.length != 0) { var travels = this.distance[0].travels this.travelDistance = travels[0].travelDistance this.travelOrder = travels[0].travelOrder this.travelTime = travels[0].travelTime this.isArrive = this.distance[0].state this.siteList = this.processArrays(this.siteList, this.stateBus, 'order', 'state'); } } } }, handleBack() { uni.navigateBack() }, async refresh() { console.log("刷新") var res = await getRealTimeBusLineStation({ lineId: this.lineId, stationName: this.stationName }) if (res.code == 0) { this.siteList = res.data.busInfStop var ind = res.data.targetOrder this.stationName = this.siteList[ind - 1].sn this.state = res.data.state this.busLineBase = res.data.busLineBase this.ind = res.data.targetOrder - 1 this.targetOrder = res.data.targetOrder this.$nextTick(function() { this.targetId = 'id' + this.siteList[ind - 4].sid }); if (this.state == 0) { this.stateBus = res.data.stateBus var travelsList = this.stateBus.travels this.distance = this.findAllClosest(this.stateBus, this .targetOrder) if (this.distance.length != 0) { var travels = this.distance[0].travels this.travelDistance = travels[0].travelDistance this.travelOrder = travels[0].travelOrder this.travelTime = travels[0].travelTime this.isArrive = this.distance[0].state this.siteList = this.processArrays(this.siteList, this .stateBus, 'order', 'state'); } } } }, // 找到距离最近车站的小车 findAllClosest(arr, target) { const validItems = arr.filter(item => item.order < target + 1); if (validItems.length === 0) return []; const distances = validItems.map(item => ({ item, distance: Math.abs(item.order - target) })); if (distances.length != 0) { const minDist = Math.min(...distances.map(d => d.distance)); return distances.filter(d => d.distance === minDist).map(d => d.item); } }, processArrays(arrayA, arrayB, key, valueKey) { // 创建arrayB的快速查找映射(基于指定键) const bMap = new Map(); arrayB.forEach(item => { if (item[key] !== undefined) { bMap.set(item[key], item); } }); // 遍历arrayA并添加属性 return arrayA.map(itemA => { // 浅拷贝避免修改原对象 const newItem = { ...itemA }; // 检查是否存在匹配元素 if (bMap.has(newItem[key])) { const matchedB = bMap.get(newItem[key]); // newItem.state = 0; newItem.isHaveBus = 0; // 添加arrayB中的属性值(如果存在) if (matchedB[valueKey] !== undefined) { newItem[valueKey] = matchedB[valueKey]; } } return newItem; }); } }, onPullDownRefresh() { console.log("下拉") this.refresh() setTimeout(() => { //结束下拉刷新 uni.stopPullDownRefresh(); }, 1000); }, onUnload() { console.log('页面即将卸载'); if (this.timer) { clearInterval(this.timer); this.timer = null; } } } </script> <style> page { background-color: #f5f5f5; } </style> <style scoped> .bg-image { position: absolute; } .custom-navbar { position: absolute; top: 0; left: 0; width: 100%; z-index: 1000; /* 自定义背景色 */ /* 自定义阴影 */ } .navbar-content { height: 44px; /* 标准导航栏高度 */ display: flex; align-items: center; padding: 0 15px; } .title { flex: 1; text-align: center; font-size: 17px; font-weight: bold; color: #333; /* 标题颜色 */ } .back-btn { width: 48rpx; height: 48rpx; } .right-area { width: 40px; text-align: right; } .info_wapper { height: 156px; /* background: #36A3F9; */ /* background: url(@/static/home/bus/detail-bg.png) left no-repeat; */ padding: 15px; color: black; position: absolute; z-index: 9; width: 100%; } .line_info { position: relative; /* display: flex; */ } .site { font-size: 32rpx; color: black; margin-bottom: 10px; text-align: left; display: flex; margin-left: 30px; } .from { /* padding-left: 52rpx; */ color: black; } .arrow { background: url(@/static/home/bus/single.png) left no-repeat; background-size: 14px 5px; margin-left: 10px; color: black; } .to { padding-left: 26px; color: black; } .time_s { background: url(@/static/home/bus/start.png) left no-repeat; background-size: 18px 18px; justify-self: baseline; } .time_e { background: url(@/static/home/bus/end.png) left no-repeat; background-size: 18px 18px; margin-left: 15px; } .price { margin-left: 15px; } .tit { color: #fff; font-size: 26rpx; /* padding-left: 52rpx; */ margin-bottom: 10px; height: 21px; color: #333; display: flex; align-items: baseline; margin-left: 30px; } .distance-class { border-radius: 15px; /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1); */ background: url(@/static/home/bus/distance-bg.png) center no-repeat; background-size: cover; height: 160px; position: absolute; z-index: 99; left: 20px; right: 20px; } .distance { color: #B7BABB; line-height: 20px; text-align: center; display: flex; flex-direction: column; align-items: center; position: relative; z-index: 99; /* align-items: baseline; */ } .time { color: aquamarine; } .bus-arr { color: rgb(255, 164, 17); font-weight: bold; margin-top: 10px; } .bus-coming { color: rgb(55, 170, 126); font-weight: bold; margin-top: 10px; } .station { margin-left: 20px; color: #353738; padding: 10px; } .station-title { display: flex; align-items: baseline; } .station-name { margin-right: 15px; } .station-content { padding-top: 10px; /* padding-left: 20rpx; */ position: relative; /* padding-right: 50rpx; */ /* 确保文字在下划线上方 */ z-index: 2; justify-content: center; display: flex; align-items: center; /* 文字在上层 */ } .underline { position: absolute; bottom: 2px; height: 3px; background: linear-gradient(to right, rgb(110, 207, 169), rgb(110, 224, 176)); /* 下划线颜色 */ border-radius: 3px; z-index: -1; width: 80%; align-items: center; justify-content: center; display: flex; /* margin-left: 30rpx; */ /* width: 60rpx; */ /* 下划线在文字下方 */ } .active { color: black; /* 激活状态文字颜色 */ font-weight: bold; /* font-size: 36rpx; */ } .time { float: left; width: 40%; font-size: 26rpx; /* height: 130rpx; */ line-height: 40px; } .time { font-size: 36rpx; color: #353738; } .time-text { margin-left: 25px; } .time_title { color: rgb(14, 170, 112); font-weight: bold; } .arr { float: left; /* width: 20%; */ font-size: 30rpx; color: rgb(14, 170, 112); } .site_list { /* margin: 15px; */ /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1); */ background-color: white; border-radius: 15px; margin-top: 150px; padding-left: 15px; padding-right: 15px; padding-top: 15px; padding-bottom: 10px; background: url(@/static/home/bus/site-bg.png) center no-repeat; position: absolute; z-index: 99; left: 20px; right: 20px; background-size: cover; /* 让背景图片覆盖整个视口 */ } .site_list .wapper_sitelist { width: 100%; overflow-x: scroll; position: relative; -webkit-overflow-scrolling: touch; display: flex; } .bus_road { background: url(@/static/home/bus/bus.png) no-repeat center; background-size: cover; width: 28px; height: 14px; position: absolute; z-index: 1; margin-top: 4px; left: 14px; /* margin-top: -40px; */ } .road-bus { background: url(@/static/home/bus/bus.png) no-repeat center; background-size: cover; width: 28px; height: 14px; position: absolute; z-index: 1; margin-top: -35px; margin-left: 10px; /* left: 14px; */ /* margin-top: -40px; */ } .road-bus-coming { background: url(@/static/home/bus/bus.png) no-repeat center; background-size: cover; width: 28px; height: 14px; position: absolute; z-index: 1; margin-top: -35px; margin-left: -40px; } .road { display: flex; } .wapper_sitelist::-webkit-scrollbar { display: none; } /deep/::-webkit-scrollbar { display: none; width: 0; height: 0; } .part { padding: 10px; display: flex; flex-direction: row; text-align: center; justify-content: center; padding-top: 30px; } .site_list .dot_r { margin-top: 25px; position: absolute; top: 23px; height: 3px; background: linear-gradient(to right, rgb(110, 207, 169), rgb(110, 224, 176)); /* 下划线颜色 */ width: 46px; border-radius: 3rpx; z-index: 1; margin-left: 4px; align-items: center; justify-content: center; display: flex; } .site_list .name { margin-top: 28px; display: flex; flex-direction: column; align-items: center; } .site_list .text { display: flex; text-align: center; margin-left: 5px; flex-direction: column; } .site_list .text_show { display: flex; text-align: center; margin-left: 5px; color: rgb(14, 170, 112); font-weight: bold; } .site_list .dot_show { background: url(@/static/home/bus/position_red.png) no-repeat center; background-size: 14px 18px; } .site_list .dot_d_show { border-radius: 50%; width: 16px; height: 16px; background-color: rgba(110, 207, 169, 0.5); position: absolute; z-index: 999; top: 41px; margin-left: 8px; display: flex; align-items: center; justify-content: center; } .road-class { display: flex; } .dot_p { border-radius: 50%; width: 8px; height: 8px; background-color: rgb(110, 207, 169); position: absolute; z-index: 999; top: 45px; display: flex; align-items: center; justify-content: center; /* margin-right: 2px; */ /* margin-left: 10rpx; */ } .dot_p_show { border-radius: 50%; width: 8px; height: 8px; background-color: rgb(14, 170, 112); position: absolute; z-index: 999; top: 45px; display: flex; align-items: center; justify-content: center; } .text-dir { margin-top: 5px; writing-mode: vertical-rl; letter-spacing: 3px; } .none { color: #848484; font-size: 16px; margin-top: 15px; } .my-map { /* width: 100%; */ position: absolute; z-index: 999; /* bottom: 20px; */ /* background-color: white; */ /* margin-bottom: 50px; */ left: 0; right: 0; top: 650px; margin: 20px; height: 370px; } .map { margin-top: 500px; margin-left: 20px; margin-right: 20px; margin-bottom: 10px; /* z-index: 9999; */ } </style> 将uniapp写法转化为h5

<template> <Search @location-selected="handleLocationSelected" /> <LocationBar v-if="loaded" :update-interval="100" :use-dms-format="useDmsFormat" /> </template> <style> /* @import "/temp/css/divGraphic.css"; */ </style> <script setup lang="ts"> import { computed, onUnmounted, onMounted, reactive } from "vue"; import LocationBar from "./location-bar.vue"; import Search from "./search.vue"; import initMap from "./init"; import { ref } from "vue"; import { throttle } from 'lodash'; import { loadRipplePoints, createMultipleRippleCircles } from './circle.js'; import { $prototype } from "../../main.ts"; const miniMapContainer = ref<HTMLElement>(); let viewIndicator: Rectangle; // 视图指示器样式 const currentPosition = reactive({ longitude: 113.361538, latitude: 27.339318, }); // 株洲市范围常量 const ZHUZHOU_EXTENT = { west: 112.5, // 株洲市西边界 east: 114.5, // 株洲市东边界 south: 26.0, // 株洲市南边界 north: 28.0 // 株洲市北边界 }; const rippleEntities = ref<any[]>([]); // 存储波纹圆实体 const heightThreshold = 80000; // 高度阈值(米),高于此值隐藏波纹圆 // 修复1:重新定义 indicatorStyle 为 ref const indicatorStyle = ref({ left: '50%', top: '50%', display: "block" }); const updateRippleVisibility = throttle(() => { if (!$prototype.$map || rippleEntities.value.length === 0) return; // 修复1:将 shouldShow 提取到块级作用域外部 let shouldShow = false; // 获取相机高度 const cartographic = $prototype.$map.camera.positionCartographic; // 修复2:添加空值检查 if (cartographic) { const cameraHeight = cartographic.height; shouldShow = cameraHeight > heightThreshold; } // 修复3:确保 shouldShow 已定义 rippleEntities.value.forEach(entity => { entity.show = shouldShow; }); }, 200); // 更新指示器位置 const updateIndicatorPosition = () => { if (!$prototype.$map) return; const camera = $prototype.$map.camera; const rect = camera.computeViewRectangle(); if (!rect) return; // 计算在株洲市范围内的相对位置 const center = Cesium.Rectangle.center(rect); const lon = Cesium.Math.toDegrees(center.longitude); const lat = Cesium.Math.toDegrees(center.latitude); // 确保位置在株洲市范围内 const constrainedLon = Math.max(ZHUZHOU_EXTENT.west, Math.min(ZHUZHOU_EXTENT.east, lon)); const constrainedLat = Math.max(ZHUZHOU_EXTENT.south, Math.min(ZHUZHOU_EXTENT.north, lat)); const lonPercent = ((constrainedLon - ZHUZHOU_EXTENT.west) / (ZHUZHOU_EXTENT.east - ZHUZHOU_EXTENT.west)) * 100; const latPercent = 100 - ((constrainedLat - ZHUZHOU_EXTENT.south) / (ZHUZHOU_EXTENT.north - ZHUZHOU_EXTENT.south)) * 100; // 更新CSS指示器 indicatorStyle.value = { left: ${lonPercent}%, top: ${latPercent}%, display: "block" }; }; // 更新鹰眼地图 - 只更新指示器位置 const updateOverview = () => { if (!$prototype.$map || !overviewViewer.value) return; // 获取主地图的当前视图中心 const rectangle = $prototype.$map.camera.computeViewRectangle(); if (!rectangle) return; // 更新指示器位置 updateIndicatorPosition(); }; const overviewViewer = ref(null); // 初始化鹰眼地图 - 使用株洲市影像 const initMiniMap = () => { Cesium.Ion.defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIxMDhlNDdmYy03NzFhLTQ1ZTQtOWQ3NS1lZDAzNDc3YjE4NDYiLCJpZCI6MzAxNzQyLCJpYXQiOjE3NDcwNTMyMDN9.eaez8rQxVbPv2LKEU0sMDclPWyHKhh1tR27Vg-_rQSM"; if (!miniMapContainer.value) return; // 创建株洲市专用影像提供器 const zhuzhouProvider = new Cesium.UrlTemplateImageryProvider({ url: "http://124.232.190.30:9000/proxy/pk1725866655224/map/zzzsyx_18/{z}/{x}/{y}.png", minimumLevel: 1, maximumLevel: 17, tilingScheme: new Cesium.WebMercatorTilingScheme(), }); // 鹰眼地图初始化 - 使用株洲市影像 overviewViewer.value = new Cesium.Viewer(miniMapContainer.value, { sceneMode: Cesium.SceneMode.SCENE2D, baseLayerPicker: false, homeButton: false, timeline: false, navigationHelpButton: false, animation: false, scene3DOnly: true, selectionIndicator: false, infoBox: false, imageryProvider: zhuzhouProvider, // 修复2:移除地形服务 terrainProvider: undefined, // 修复3:使用正确的投影 mapProjection: new Cesium.WebMercatorProjection(), // 修复4:禁用天空盒和大气层 skyBox: false, skyAtmosphere: false }); // 设置固定视野为株洲市范围 overviewViewer.value.camera.setView({ destination: Cesium.Rectangle.fromDegrees( ZHUZHOU_EXTENT.west, ZHUZHOU_EXTENT.south, ZHUZHOU_EXTENT.east, ZHUZHOU_EXTENT.north ) }); // 隐藏控件 const toolbar = overviewViewer.value.container.getElementsByClassName("cesium-viewer-toolbar")[0]; if (toolbar) toolbar.style.display = "none"; // 修复5:隐藏版权信息 overviewViewer.value.cesiumWidget.creditContainer.style.display = "none"; // 初始化视图指示器 initRectangle(); }; // 初始化视图指示器 function initRectangle() { // 创建视图指示器(株洲市范围框) viewIndicator = overviewViewer.value.entities.add({ rectangle: { coordinates: Cesium.Rectangle.fromDegrees( ZHUZHOU_EXTENT.west, ZHUZHOU_EXTENT.south, ZHUZHOU_EXTENT.east, ZHUZHOU_EXTENT.north ), material: Cesium.Color.RED.withAlpha(0.3), outline: true, outlineColor: Cesium.Color.RED, outlineWidth: 2, }, }); } const loaded = ref(false); const useDmsFormat = ref(false); function addDemoGraphics() { const chinaBoundary = $prototype.$map.dataSources.add( Cesium.GeoJsonDataSource.load("/shp_zz.geojson", { stroke: Cesium.Color.WHITE, fill: false, clampToGround: true, describe: null, }) ); chinaBoundary.then((dataSource) => { const entities = dataSource.entities.values; for (let entity of entities) { if (entity.polyline) { entity.polyline.fill = false; } } }); } function flyToDes() { const center = Cesium.Cartesian3.fromDegrees(-98.0, 40.0); $prototype.$map.camera.flyTo({ destination: new Cesium.Cartesian3( -2432812.6687511606, 5559483.804371395, 2832009.419525571 ), orientation: { heading: 6.283185307179421, pitch: -1.0472145569408116, roll: 6.2831853071795205, }, complete: function () {}, }); } // 监听主地图相机变化 const setupCameraListener = () => { $prototype.$map.camera.changed.addEventListener(updateOverview); }; // 鹰眼地图点击处理 const handleMiniMapClick = (event: MouseEvent) => { if (!miniMapContainer.value || !overviewViewer.value) return; const rect = miniMapContainer.value.getBoundingClientRect(); const x = event.clientX - rect.left; const y = event.clientY - rect.top; // 计算在固定范围内的相对位置 const xPercent = (x / rect.width) * 100; const yPercent = (y / rect.height) * 100; // 转换为株洲市范围内的经纬度 const lon = ZHUZHOU_EXTENT.west + (xPercent / 100) * (ZHUZHOU_EXTENT.east - ZHUZHOU_EXTENT.west); const lat = ZHUZHOU_EXTENT.north - (yPercent / 100) * (ZHUZHOU_EXTENT.north - ZHUZHOU_EXTENT.south); // 主地图飞向点击位置 $prototype.$map.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(lon, lat, 1000000), }); }; function addImage() { var rightImageProvider = new Cesium.UrlTemplateImageryProvider({ name: "影像图", type: "xyz", layer: "vec_d", url: "http://124.232.190.30:9000/proxy/pk1725866655224/map/zzzsyx_18/{z}/{x}/{y}.png", minimumLevel: 1, maximumLevel: 17, crs: "EPSG:3857", }); $prototype.$map.imageryLayers.addImageryProvider(rightImageProvider); rightImageProvider.splitDirection = Cesium.SplitDirection.right; } onMounted(() => { initMap(); addImage(); loaded.value = true; addDemoGraphics(); flyToDes(); // 修复6:确保正确的初始化顺序 setTimeout(() => { initMiniMap(); setupCameraListener(); // 初始更新 updateOverview(); }, 1000); (async () => { try { const ripplePoints = await loadRipplePoints(); rippleEntities.value = createMultipleRippleCircles( $prototype.$map, ripplePoints ); $prototype.$map.camera.changed.addEventListener(updateRippleVisibility); updateRippleVisibility(); } catch (error) { console.error('加载波纹圆失败:', error); } })(); }); let currentMarker: any = null; const createMarker = (location: { lng: number; lat: number; name: string }) => { if (currentMarker) { $prototype.$map.entities.remove(currentMarker); } currentMarker = $prototype.$map.entities.add({ position: Cesium.Cartesian3.fromDegrees( location.lng, location.lat, 50 ), point: { pixelSize: 200, color: Cesium.Color.RED, outlineColor: Cesium.Color.WHITE, outlineWidth: 2, heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND, }, label: { text: location.name, font: "40px sans-serif", fillColor: Cesium.Color.WHITE, outlineColor: Cesium.Color.BLACK, outlineWidth: 1, verticalOrigin: Cesium.VerticalOrigin.BOTTOM, pixelOffset: new Cesium.Cartesian2(0, -20), heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND, distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 10000), }, description: ${location.name} 经度:${location.lng.toFixed(6)} 纬度:${location.lat.toFixed(6)} , }); return currentMarker; }; const handleLocationSelected = (location: { lng: number; lat: number; name: string; }) => { if (!$prototype.$map) return; const destination = Cesium.Cartesian3.fromDegrees( location.lng, location.lat, 200 ); $prototype.$map.camera.flyTo({ destination, orientation: { heading: Cesium.Math.toRadians(0), pitch: Cesium.Math.toRadians(-45), roll: 0, }, duration: 2, complete: () => { createMarker(location); }, }); }; onUnmounted(() => { if ($prototype.$map) { $prototype.$map.destroy(); $prototype.$map = null; } if ($prototype.$map) { $prototype.$map.camera.changed.removeEventListener(updateRippleVisibility); } console.log("组件销毁"); }); const emit = defineEmits(["onload", "onclick"]); const initMars3d = async (option: any) => { emit("onclick", true); emit("onload", $prototype.$map); }; </script> <style lang="less"> /**cesium 工具按钮栏*/ .cesium-viewer-toolbar { top: auto !important; bottom: 35px !important; left: 12px !important; right: auto !important; } .cesium-toolbar-button img { height: 100%; } .cesium-viewer-toolbar > .cesium-toolbar-button, .cesium-navigationHelpButton-wrapper, .cesium-viewer-geocoderContainer { margin-bottom: 5px; float: left; clear: both; text-align: center; } .cesium-button { background-color: rgba(23, 49, 71, 0.8); color: #e6e6e6; fill: #e6e6e6; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); line-height: 32px; } .cesium-button:hover { background: #3ea6ff; } /**cesium 底图切换面板*/ .cesium-baseLayerPicker-dropDown { bottom: 0; left: 40px; max-height: 700px; margin-bottom: 5px; background-color: rgba(23, 49, 71, 0.8); } /**cesium 帮助面板*/ .cesium-navigation-help { top: auto; bottom: 0; left: 40px; transform-origin: left bottom; background: none; background-color: rgba(23, 49, 71, 0.8); .cesium-navigation-help-instructions { background: none; } .cesium-navigation-button { background: none; } .cesium-navigation-button-selected, .cesium-navigation-button-unselected:hover { background: rgba(0, 138, 255, 0.2); } } /**cesium 二维三维切换*/ .cesium-sceneModePicker-wrapper { width: auto; } .cesium-sceneModePicker-wrapper .cesium-sceneModePicker-dropDown-icon { float: right; margin: 0 3px; } /**cesium POI查询输入框*/ .cesium-viewer-geocoderContainer .search-results { left: 0; right: 40px; width: auto; z-index: 9999; } .cesium-geocoder-searchButton { background-color: rgba(23, 49, 71, 0.8); } .cesium-viewer-geocoderContainer .cesium-geocoder-input { background-color: rgba(63, 72, 84, 0.7); } .cesium-viewer-geocoderContainer .cesium-geocoder-input:focus { background-color: rgba(63, 72, 84, 0.9); } .cesium-viewer-geocoderContainer .search-results { background-color: rgba(23, 49, 71, 0.8); } /**cesium info信息框*/ .cesium-infoBox { top: 50px; background-color: rgba(23, 49, 71, 0.8); } .cesium-infoBox-title { background-color: rgba(23, 49, 71, 0.8); } /**cesium 任务栏的FPS信息*/ .cesium-performanceDisplay-defaultContainer { top: auto; bottom: 35px; right: 50px; } .cesium-performanceDisplay-ms, .cesium-performanceDisplay-fps { color: #fff; } /**cesium tileset调试信息面板*/ .cesium-viewer-cesiumInspectorContainer { top: 10px; left: 10px; right: auto; } .cesium-cesiumInspector { background-color: rgba(23, 49, 71, 0.8); } /**覆盖mars3d内部控件的颜色等样式*/ .mars3d-compass .mars3d-compass-outer { fill: rgba(23, 49, 71, 0.8); } .mars3d-contextmenu-ul, .mars3d-sub-menu { background-color: rgba(23, 49, 71, 0.8); > li > a:hover, > li > a:focus, > li > .active { background-color: #3ea6ff; } > .active > a, > .active > a:hover, > .active > a:focus { background-color: #3ea6ff; } } /* Popup样式*/ .mars3d-popup-color { color: #ffffff; } .mars3d-popup-background { background: rgba(23, 49, 71, 0.8); } .mars3d-popup-content { margin: 15px; } .mars3d-template-content label { padding-right: 6px; } .mars3d-template-titile { border-bottom: 1px solid #3ea6ff; } .mars3d-template-titile a { font-size: 16px; } .mars3d-tooltip { background: rgba(23, 49, 71, 0.8); border: 1px solid rgba(23, 49, 71, 0.8); } .mars3d-popup-btn-custom { padding: 3px 10px; border: 1px solid #209ffd; background: #209ffd1c; } .mars-dialog .mars-dialog__content { height: 100%; width: 100%; overflow: auto; padding: 5px; } .image { border: solid 2px #fff; } .content { height: 90%; padding-top: 10px; overflow-x: auto; overflow-y: auto; } .content-text { padding: 0 10px; text-indent: 30px; font-size: 17px; } .details-video { width: 100%; height: 760px; background-color: #000; } :where(.css-lt97qq9).ant-space { display: inline-flex; } :where(.css-lt97qq9).ant-space-align-center { align-items: center; } :where(.css-lt97qq9).ant-image .ant-image-mask { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; background: rgba(0, 0, 0, 0.5); cursor: pointer; opacity: 0; transition: opacity 0.3s; } :where(.css-lt97qq9).ant-image .ant-image-mask .ant-image-mask-info { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 4px; } :where(.css-1t97qq9)[class^="ant-image"] [class^="ant-image"], :where(.css-1t97qq9)[class*=" ant-image"] [class^="ant-image"], :where(.css-1t97qq9)[class^="ant-image"] [class*=" ant-image"], :where(.css-1t97qq9)[class*=" ant-image"] [class*=" ant-image"] { box-sizing: border-box; } :where(.css-lt97qq9).ant-image .ant-image-img { width: 100%; height: auto; vertical-align: middle; } </style> <style scoped> .mini-map-container { position: relative; width: 100%; height: 100%; } .main-viewer { width: 100%; height: 100%; } .mini-map { position: absolute; right: 3vw; bottom: 6vh; width: 12vw; height: 17vh; border: 2px solid #fff; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); z-index: 999; cursor: pointer; overflow: hidden; } .location-indicator { position: absolute; width: 14px; height: 14px; background: #ff3e3e; border: 2px solid white; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 15px rgba(255, 62, 62, 1); z-index: 100; } .view-rectangle { position: absolute; border: 2px solid #00f2fe; z-index: 99; pointer-events: none; box-shadow: 0 0 20px rgba(0, 242, 254, 0.7); } /* 相机聚焦样式 - 四个角折角 */ .corner { position: absolute; width: 25px; height: 25px; z-index: 100; pointer-events: none; } .corner::before, .corner::after { content: ""; position: absolute; background: #00f2fe; box-shadow: 0 0 10px rgba(0, 242, 254, 0.8); } .corner-top-left { top: -2px; left: -2px; } .corner-top-left::before { top: 0; left: 0; width: 15px; height: 3px; } .corner-top-left::after { top: 0; left: 0; width: 3px; height: 15px; } .corner-top-right { top: -2px; right: -2px; } .corner-top-right::before { top: 0; right: 0; width: 15px; height: 3px; } .corner-top-right::after { top: 0; right: 0; width: 3px; height: 15px; } .corner-bottom-left { bottom: -2px; left: -2px; } .corner-bottom-left::before { bottom: 0; left: 0; width: 15px; height: 3px; } .corner-bottom-left::after { bottom: 0; left: 0; width: 3px; height: 15px; } .corner-bottom-right { bottom: -2px; right: -2px; } .corner-bottom-right::before { bottom: 0; right: 0; width: 15px; height: 3px; } .corner-bottom-right::after { bottom: 0; right: 0; width: 3px; height: 15px; } .camera-icon { position: absolute; top: 10px; right: 10px; color: #00f2fe; font-size: 24px; z-index: 100; text-shadow: 0 0 10px rgba(0, 242, 254, 0.8); } .focus-effect { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 98; border: 2px solid rgba(0, 242, 254, 0.2); border-radius: 5px; box-shadow: inset 0 0 30px rgba(0, 242, 254, 0.1); } .pulse { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 10px; height: 10px; border-radius: 50%; background: rgba(0, 242, 254, 0.7); box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.7); animation: pulse 2s infinite; } ::v-deep.cesium-viewer-toolbar { display: none; } </style> 如上vue代码,还有个问题,就是鹰眼地图里面除了中间的株洲影像不变以外,其余地方加载的还是原本初始的地球影像即可,现在鹰眼地图里面只有这个株洲影像,你尝试修改一下代码,尽可能减少对vue其他无关代码的更改

请生成新代码 使得webview嵌在页面内可以跟随页面移动 <template> <view class="wapper"> <image class="bg-image" src="/https/wenku.csdn.net/static/home/bus/bg-image.png" mode="widthFix" style="width: 100%;" /> <view class="custom-navbar" :style="{ paddingTop: statusBarHeight + 'px' }"> <view class="navbar-content"> <view class="back-btn" @click="handleBack"> <image src="/https/wenku.csdn.net/static/home/bus/back-icon.png" mode="aspectFit" style="width: 48rpx;height: 48rpx;" /> </view> <text class="title">{{busLineBase.name}}</text> </view> </view> <view class="wapper-content" :style="{ paddingTop: statusBarHeight +50 + 'px' }"> <view class="line_info"> <view class="site"> <text class="from">{{busLineBase.startSn}}</text> <view class="arrow"> <text class="to">{{busLineBase.endSn}}</text> </view> </view> <view class="tit"> <view class="time_s"> <text class="time-text">{{busLineBase.firstTime}}</text> </view> <view class="time_e"> <text class="time-text">{{busLineBase.lastTime}}</text> </view> <text class="price">票价: {{busLineBase.price}}</text> </view> </view> <view class="distance-class"> <view class="station"> <view class="station-title"> <view class="station-name">候车站</view> <view class="station-content"> <view class="active">{{stationName}}</view> <view class="underline"></view> </view> </view> </view> <view class="distance" v-if="state==0 && travelOrder!=0"> <view class="time"> <text class="time_title">{{Math.ceil(travelTime/60)}}分钟</text> </view> <text class="arr">{{travelOrder}}站/ <text v-if="travelDistance<1000">{{numFilter(travelDistance)}}m</text> <text v-else>{{numFilter(travelDistance/1000)}}km</text> </text> </view> <view class="distance" v-else-if="state==0 && travelOrder==0 && isArrive==1"> <view class="time"> <view class="bus-arr">已到站</view> </view> </view> <view class="distance" v-else-if="state==0 &&isArrive==0"> <view class="time"> <view class="bus-coming">即将到站 {{travelDistance}}m</view> </view> </view> <view class="distance" v-else-if="state==-1"> <view class="time"> <view class="none">等待发车</view> </view> </view> <view class="distance" v-else> <view class="time"> <view class="none">暂无车辆信息</view> </view> </view> </view> </view> <view class="site_list"> <view> <scroll-view class="wapper_sitelist" scroll-x="true" scroll-with-animation :scroll-into-view="targetId"> <view class="road"> <view class='part' v-for="(item, index) in siteList" @click="showActive(index, item.sn)"> <view :id="'id'+item.sid" class='name'> <view> <view class="dot_p" :class="{'dot_p_show': ind === index}"></view> <view class='dot_r' v-if="index!=siteList.length-1"></view> </view> <view class='dot_d' :class="{'dot_d_show': ind === index}"></view> <view class='text' :class="{'text_show': ind === index}"> <view>{{index +1}}</view> <view class="text-dir"> {{item.sn}} </view> </view> </view> </view> </view> </scroll-view> </view> </view> <view> <web-view ref="webview" :webview-styles="webviewStyles" :src="src" :fullscreen="false"></web-view> </view> </iframe> </view> </template> <script> import { getRealTimeBusLine, getRealTimeBusLineStation } from '@/request/bus.js' export default { data() { return { src: './static/web/map.html', timer: null, isArrive: 0, targetId: '', state: 0, stationName: '', travelDistance: 0, travelTime: 0, travelOrder: 0, ratio: '', ind: '', siteId: "", lineName: "二号线", siteName: "动漫园站", siteList: [], busLineBase: [], stateBus: [], time_s: '', time_e: '', from: '', busPosition: [0, 5, 11], to: '', isActive: false, lineId: '', siteNum: '0', haveBus: true, webviewStyles: { position: 'relative', top: '580px', // bottom: '30px', zindex: '9999', // marginTop: '850px', left: '20px', right: '20px', // height:'300px' // height: '500px', }, id: 0, // 使用 marker点击事件 需要填写id title: 'map', latitude: 39.90923, longitude: 116.397428, covers: [{ latitude: 39.909, longitude: 116.39742, iconPath: '../../../static/location.png' }, { latitude: 39.90, longitude: 116.39, iconPath: '../../../static/location.png' }] } }, onLoad(options) { // 获取路由参数 const { statusBarHeight } = uni.getSystemInfoSync() // const systemInfo = uni.getSystemInfoSync(); // this.ratio = (systemInfo.windowWidth / 750) / 0.5 console.log("options", options) this.statusBarHeight = statusBarHeight this.lineId = options.lineId this.lat = options.lat this.lng = options.lng this.lineName = options.lineName this.getLineDetail() if (this.timer) { clearInterval(this.timer); this.timer = null; } // this.timer = setInterval(() => { // console.log("30") // this.refresh() // }, 1000 * 30); // this.$nextTick(function() { // 仅 App 平台执行 // amap.initMap('amap', 'cd0bbe150380e1263de209abf425745b'); this.init() // }) }, methods: { // vue向iframe传递信息 init() { this.src = "../../../../hybrid/html/map.html" // var res = { // lineName:this.lineName // } // this.src = './static/map.html?data=' + encodeURIComponent(JSON.stringify({ // ...res // })) // var lineName = this.lineName // const iframeWindow = this.$refs.iframe.contentWindow; // this.dom = document.getElementById('iframe') // iframeWindow.postMessage({ // cmd: 'myVue', // params: { // info: 'Vue向iframe传递的消息', // } // }, '*') }, numFilter(value) { if (value != 0) { // 将数值转换为浮点数,并保留两位小数 let realVal = parseFloat(value).toFixed(2); return realVal; } }, async getLineDetail() { var res = await getRealTimeBusLine({ lineId: this.lineId, lat: this.lat, lng: this.lng }) if (res.code == 0) { console.log("1", res) this.siteList = res.data.busInfStop var ind = res.data.targetOrder this.ind = res.data.targetOrder - 1 this.stationName = this.siteList[ind - 1].sn this.state = res.data.state this.busLineBase = res.data.busLineBase this.targetOrder = res.data.targetOrder this.$nextTick(function() { this.targetId = 'id' + this.siteList[ind - 4].sid }); if (this.state == 0) { this.stateBus = res.data.stateBus var travelsList = this.stateBus.travels this.distance = this.findAllClosest(this.stateBus, this.targetOrder) if (this.distance.length != 0) { var travels = this.distance[0].travels this.travelDistance = travels[0].travelDistance this.travelOrder = travels[0].travelOrder this.travelTime = travels[0].travelTime this.siteList = this.processArrays(this.siteList, this.stateBus, 'order', 'state'); } } } }, async showActive(index, siteName) { this.ind = index this.stationName = siteName var res = await getRealTimeBusLineStation({ lineId: this.lineId, stationName: this.stationName }) if (res.code == 0) { this.siteList = res.data.busInfStop var ind = res.data.targetOrder this.stationName = this.siteList[ind - 1].sn this.state = res.data.state this.busLineBase = res.data.busLineBase this.ind = res.data.targetOrder - 1 this.targetOrder = res.data.targetOrder this.$nextTick(function() { this.targetId = 'id' + this.siteList[ind - 4].sid }); if (this.state == 0) { this.stateBus = res.data.stateBus var travelsList = this.stateBus.travels this.distance = this.findAllClosest(this.stateBus, this.targetOrder) if (this.distance.length != 0) { var travels = this.distance[0].travels this.travelDistance = travels[0].travelDistance this.travelOrder = travels[0].travelOrder this.travelTime = travels[0].travelTime this.isArrive = this.distance[0].state this.siteList = this.processArrays(this.siteList, this.stateBus, 'order', 'state'); } } } }, handleBack() { uni.navigateBack() }, async refresh() { console.log("刷新") var res = await getRealTimeBusLineStation({ lineId: this.lineId, stationName: this.stationName }) if (res.code == 0) { this.siteList = res.data.busInfStop var ind = res.data.targetOrder this.stationName = this.siteList[ind - 1].sn this.state = res.data.state this.busLineBase = res.data.busLineBase this.ind = res.data.targetOrder - 1 this.targetOrder = res.data.targetOrder this.$nextTick(function() { this.targetId = 'id' + this.siteList[ind - 4].sid }); if (this.state == 0) { this.stateBus = res.data.stateBus var travelsList = this.stateBus.travels this.distance = this.findAllClosest(this.stateBus, this .targetOrder) if (this.distance.length != 0) { var travels = this.distance[0].travels this.travelDistance = travels[0].travelDistance this.travelOrder = travels[0].travelOrder this.travelTime = travels[0].travelTime this.isArrive = this.distance[0].state this.siteList = this.processArrays(this.siteList, this .stateBus, 'order', 'state'); } } } }, // 找到距离最近车站的小车 findAllClosest(arr, target) { const validItems = arr.filter(item => item.order < target + 1); if (validItems.length === 0) return []; const distances = validItems.map(item => ({ item, distance: Math.abs(item.order - target) })); if (distances.length != 0) { const minDist = Math.min(...distances.map(d => d.distance)); return distances.filter(d => d.distance === minDist).map(d => d.item); } }, processArrays(arrayA, arrayB, key, valueKey) { // 创建arrayB的快速查找映射(基于指定键) const bMap = new Map(); arrayB.forEach(item => { if (item[key] !== undefined) { bMap.set(item[key], item); } }); // 遍历arrayA并添加属性 return arrayA.map(itemA => { // 浅拷贝避免修改原对象 const newItem = { ...itemA }; // 检查是否存在匹配元素 if (bMap.has(newItem[key])) { const matchedB = bMap.get(newItem[key]); // newItem.state = 0; newItem.isHaveBus = 0; // 添加arrayB中的属性值(如果存在) if (matchedB[valueKey] !== undefined) { newItem[valueKey] = matchedB[valueKey]; } } return newItem; }); } }, onPullDownRefresh() { console.log("下拉") this.refresh() setTimeout(() => { //结束下拉刷新 uni.stopPullDownRefresh(); }, 1000); }, onUnload() { console.log('页面即将卸载'); if (this.timer) { clearInterval(this.timer); this.timer = null; } }, } </script> <style> page { background-color: #f5f5f5; } </style> <style scoped> .bg-image { position: absolute; } .custom-navbar { position: absolute; top: 0; left: 0; width: 100%; z-index: 1000; /* 自定义背景色 */ /* 自定义阴影 */ } .navbar-content { height: 44px; /* 标准导航栏高度 */ display: flex; align-items: center; padding: 0 15px; } .title { flex: 1; text-align: center; font-size: 17px; font-weight: bold; color: #333; /* 标题颜色 */ } .back-btn { width: 48rpx; height: 48rpx; } .right-area { width: 40px; text-align: right; } .info_wapper { height: 156px; /* background: #36A3F9; */ /* background: url(@/static/home/bus/detail-bg.png) left no-repeat; */ padding: 15px; color: black; position: absolute; z-index: 9; width: 100%; } .line_info { position: relative; /* display: flex; */ } .site { font-size: 32rpx; color: black; margin-bottom: 10px; text-align: left; display: flex; margin-left: 30px; } .from { /* padding-left: 52rpx; */ color: black; } .arrow { background: url(@/static/home/bus/single.png) left no-repeat; background-size: 14px 5px; margin-left: 10px; color: black; } .to { padding-left: 26px; color: black; } .time_s { background: url(@/static/home/bus/start.png) left no-repeat; background-size: 18px 18px; justify-self: baseline; } .time_e { background: url(@/static/home/bus/end.png) left no-repeat; background-size: 18px 18px; margin-left: 15px; } .price { margin-left: 15px; } .tit { color: #fff; font-size: 26rpx; /* padding-left: 52rpx; */ margin-bottom: 10px; height: 21px; color: #333; display: flex; align-items: baseline; margin-left: 30px; } .distance-class { border-radius: 15px; /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1); */ background: url(@/static/home/bus/distance-bg.png) center no-repeat; background-size: cover; height: 150px; position: absolute; z-index: 9999; left: 20px; right: 20px; } .distance { color: #B7BABB; line-height: 20px; text-align: center; display: flex; flex-direction: column; align-items: center; position: relative; z-index: 9999; /* align-items: baseline; */ } .time { color: aquamarine; } .bus-arr { color: rgb(255, 164, 17); font-weight: bold; margin-top: 10px; } .bus-coming { color: rgb(55, 170, 126); font-weight: bold; line-height: 100rpx; } .station { margin-left: 20px; color: #353738; padding: 10px; } .station-title { display: flex; align-items: baseline; } .station-name { margin-right: 15px; } .station-content { padding-top: 10px; /* padding-left: 20rpx; */ position: relative; /* padding-right: 50rpx; */ /* 确保文字在下划线上方 */ z-index: 2; justify-content: center; display: flex; align-items: center; /* 文字在上层 */ } .underline { position: absolute; bottom: 2px; height: 3px; background: linear-gradient(to right, rgb(110, 207, 169), rgb(110, 224, 176)); /* 下划线颜色 */ border-radius: 3px; z-index: -1; width: 80%; align-items: center; justify-content: center; display: flex; /* margin-left: 30rpx; */ /* width: 60rpx; */ /* 下划线在文字下方 */ } .active { color: black; /* 激活状态文字颜色 */ font-weight: bold; /* font-size: 36rpx; */ } .time { float: left; width: 40%; font-size: 26rpx; /* height: 130rpx; */ line-height: 30px; } .time { font-size: 36rpx; color: #353738; } .time-text { margin-left: 25px; } .time_title { color: rgb(14, 170, 112); font-weight: bold; } .arr { float: left; /* width: 20%; */ font-size: 30rpx; color: rgb(14, 170, 112); } .site_list { /* margin: 15px; */ /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1); */ /* background-color: white; */ border-radius: 15px; margin-top: 140px; padding-left: 15px; padding-right: 15px; padding-top: 15px; padding-bottom: 10px; background: url(@/static/home/bus/site-bg.png) center no-repeat; position: absolute; z-index: 9999; left: 20px; right: 20px; background-size: cover; /* 让背景图片覆盖整个视口 */ } .site_list .wapper_sitelist { width: 100%; overflow-x: scroll; position: relative; -webkit-overflow-scrolling: touch; display: flex; /* margin-bottom: 200px; */ } .bus_road { background: url(@/static/home/bus/bus.png) no-repeat center; background-size: cover; width: 28px; height: 14px; position: absolute; z-index: 1; margin-top: 4px; left: 14px; /* margin-top: -40px; */ } .road-bus { background: url(@/static/home/bus/bus.png) no-repeat center; background-size: cover; width: 28px; height: 14px; position: absolute; z-index: 1; margin-top: -45px; margin-left: 10px; /* left: 14px; */ /* margin-top: -40px; */ } .road-bus-coming { background: url(@/static/home/bus/bus.png) no-repeat center; background-size: cover; width: 28px; height: 14px; position: absolute; z-index: 1; margin-top: -45px; margin-left: -40px; } .road { display: flex; } .wapper_sitelist::-webkit-scrollbar { display: none; } /deep/::-webkit-scrollbar { display: none; width: 0; height: 0; } .part { padding: 10px; display: flex; flex-direction: row; text-align: center; justify-content: center; padding-top: 20px; } .site_list .dot_r { margin-top: 10px; position: absolute; top: 23px; height: 3px; background: linear-gradient(to right, rgb(110, 207, 169), rgb(110, 224, 176)); /* 下划线颜色 */ width: 46px; border-radius: 3rpx; z-index: 1; margin-left: 4px; align-items: center; justify-content: center; display: flex; } .site_list .name { margin-top: 28px; display: flex; flex-direction: column; align-items: center; } .site_list .text { display: flex; text-align: center; margin-left: 5px; flex-direction: column; } .site_list .text_show { display: flex; text-align: center; margin-left: 5px; color: rgb(14, 170, 112); font-weight: bold; } .site_list .dot_show { background: url(@/static/home/bus/position_red.png) no-repeat center; background-size: 14px 18px; } .site_list .dot_d_show { border-radius: 50%; width: 16px; height: 16px; background-color: rgba(110, 207, 169, 0.5); position: absolute; z-index: 9999; top: 26px; margin-left: 8px; display: flex; align-items: center; justify-content: center; } .road-class { display: flex; } .dot_p { border-radius: 50%; width: 8px; height: 8px; background-color: rgb(110, 207, 169); position: absolute; z-index: 9999; top: 30px; display: flex; align-items: center; justify-content: center; /* margin-right: 2px; */ /* margin-left: 10rpx; */ } .dot_p_show { border-radius: 50%; width: 8px; height: 8px; background-color: rgb(14, 170, 112); position: absolute; z-index: 9999; top: 30px; display: flex; align-items: center; justify-content: center; } .text-dir { margin-top: 5px; writing-mode: vertical-rl; letter-spacing: 1px; } .none { color: #848484; font-size: 16px; margin-top: 15px; } .map { /* margin-top: 450px; */ position: absolute; z-index: 999; margin-top: 480px; /* height: 300px; */ } .web-class { /* top: 800px; */ /* height: 300px; */ /* position: absolute; z-index: 99999; */ width: 100%; margin-top: 500px; } .page-body { margin-top: 250px; padding-bottom: 20px; } </style>

Uncaught ReferenceError: indicatorStyle is not defined at updateIndicatorPosition (live-map.vue:85:3) at initMiniMap (live-map.vue:161:3) at live-map.vue:276:5 如上所示报错,鹰眼地图还是只有那个株洲影像其他都没有,为全蓝色,修改以下代码:<template> <Search @location-selected="handleLocationSelected" /> <LocationBar v-if="loaded" :update-interval="100" :use-dms-format="useDmsFormat" /> </template> <style> /* @import "/temp/css/divGraphic.css"; */ </style> <script setup lang="ts"> import { computed, onUnmounted, onMounted, reactive } from "vue"; import LocationBar from "./location-bar.vue"; import Search from "./search.vue"; import initMap from "./init"; import { ref } from "vue"; import { throttle } from 'lodash'; import { loadRipplePoints, createMultipleRippleCircles } from './circle.js'; import { $prototype } from "../../main.ts"; const miniMapContainer = ref<HTMLElement>(); let viewIndicator: Rectangle; // 视图指示器样式 const currentPosition = reactive({ longitude: 113.361538, latitude: 27.339318, }); // 株洲市范围常量 const ZHUZHOU_EXTENT = { west: 112.5, // 株洲市西边界 east: 114.5, // 株洲市东边界 south: 26.0, // 株洲市南边界 north: 28.0 // 株洲市北边界 }; const rippleEntities = ref<any[]>([]); // 存储波纹圆实体 const heightThreshold = 80000; // 高度阈值(米),高于此值隐藏波纹圆 const updateRippleVisibility = throttle(() => { if (!$prototype.$map || rippleEntities.value.length === 0) return; // 添加缺失的相机高度计算和显示判断 const cameraHeight = $prototype.$map.camera.positionCartographic.height; const shouldShow = cameraHeight > heightThreshold; rippleEntities.value.forEach(entity => { entity.show = shouldShow; }); }, 200); // 更新指示器位置 const updateIndicatorPosition = () => { if (!$prototype.$map) return; const camera = $prototype.$map.camera; const rect = camera.computeViewRectangle(); if (!rect) return; // 计算在株洲市范围内的相对位置 const center = Cesium.Rectangle.center(rect); const lon = Cesium.Math.toDegrees(center.longitude); const lat = Cesium.Math.toDegrees(center.latitude); const lonPercent = ((lon - ZHUZHOU_EXTENT.west) / (ZHUZHOU_EXTENT.east - ZHUZHOU_EXTENT.west)) * 100; const latPercent = 100 - ((lat - ZHUZHOU_EXTENT.south) / (ZHUZHOU_EXTENT.north - ZHUZHOU_EXTENT.south)) * 100; // 更新CSS指示器 indicatorStyle.value = { left: ${lonPercent}%, top: ${latPercent}%, display: "block" }; }; // 更新鹰眼地图 - 只更新指示器位置 const updateOverview = () => { if (!$prototype.$map || !overviewViewer.value) return; // 获取主地图的当前视图中心 const rectangle = $prototype.$map.camera.computeViewRectangle(); if (!rectangle) return; const center = Cesium.Rectangle.center(rectangle); currentPosition.longitude = Cesium.Math.toDegrees(center.longitude); currentPosition.latitude = Cesium.Math.toDegrees(center.latitude); // 更新指示器位置 updateIndicatorPosition(); }; const overviewViewer = ref(null); // 初始化鹰眼地图 - 使用株洲市影像 const initMiniMap = () => { Cesium.Ion.defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIxMDhlNDdmYy03NzFhLTQ1ZTQtOWQ3NS1lZDAzNDc3YjE4NDYiLCJpZCI6MzAxNzQyLCJpYXQiOjE3NDcwNTMyMDN9.eaez8rQxVbPv2LKEU0sMDclPWyHKhh1tR27Vg-_rQSM"; if (!miniMapContainer.value) return; // 创建株洲市专用影像提供器 const zhuzhouProvider = new Cesium.UrlTemplateImageryProvider({ url: "http://124.232.190.30:9000/proxy/pk1725866655224/map/zzzsyx_18/{z}/{x}/{y}.png", minimumLevel: 1, maximumLevel: 17, crs: "EPSG:3857", tilingScheme: new Cesium.WebMercatorTilingScheme(), // 修复2:明确使用墨卡托投影 }); // 鹰眼地图初始化 - 使用株洲市影像 overviewViewer.value = new Cesium.Viewer(miniMapContainer.value, { sceneMode: Cesium.SceneMode.SCENE2D, baseLayerPicker: false, homeButton: false, timeline: false, navigationHelpButton: false, animation: false, scene3DOnly: true, selectionIndicator: false, infoBox: false, imageryProvider: zhuzhouProvider, // 修复3:移除地形服务,避免蓝色背景 terrainProvider: undefined, // 修复4:设置正确的投影 mapProjection: new Cesium.WebMercatorProjection(), }); // 设置固定视野为株洲市范围 overviewViewer.value.camera.setView({ destination: Cesium.Rectangle.fromDegrees( ZHUZHOU_EXTENT.west, ZHUZHOU_EXTENT.south, ZHUZHOU_EXTENT.east, ZHUZHOU_EXTENT.north ) }); // 隐藏控件 const toolbar = overviewViewer.value.container.getElementsByClassName("cesium-viewer-toolbar")[0]; if (toolbar) toolbar.style.display = "none"; overviewViewer.value.cesiumWidget.creditContainer.style.display = "none"; // 修复5:初始化视图指示器 initRectangle(); // 修复6:初始更新指示器位置 updateIndicatorPosition(); }; // 初始化视图指示器 function initRectangle() { // 创建视图指示器(株洲市范围框) viewIndicator = overviewViewer.value.entities.add({ rectangle: { coordinates: Cesium.Rectangle.fromDegrees( ZHUZHOU_EXTENT.west, ZHUZHOU_EXTENT.south, ZHUZHOU_EXTENT.east, ZHUZHOU_EXTENT.north ), material: Cesium.Color.RED.withAlpha(0.3), outline: true, outlineColor: Cesium.Color.RED, outlineWidth: 2, }, }); } const loaded = ref(false); const useDmsFormat = ref(false); function addDemoGraphics() { const chinaBoundary = $prototype.$map.dataSources.add( Cesium.GeoJsonDataSource.load("/shp_zz.geojson", { stroke: Cesium.Color.WHITE, fill: false, clampToGround: true, describe: null, }) ); chinaBoundary.then((dataSource) => { const entities = dataSource.entities.values; for (let entity of entities) { if (entity.polyline) { entity.polyline.fill = false; } } }); } function flyToDes() { const center = Cesium.Cartesian3.fromDegrees(-98.0, 40.0); $prototype.$map.camera.flyTo({ destination: new Cesium.Cartesian3( -2432812.6687511606, 5559483.804371395, 2832009.419525571 ), orientation: { heading: 6.283185307179421, pitch: -1.0472145569408116, roll: 6.2831853071795205, }, complete: function () {}, }); } // 监听主地图相机变化 const setupCameraListener = () => { $prototype.$map.camera.changed.addEventListener(updateOverview); }; // 鹰眼地图点击处理 const handleMiniMapClick = (event: MouseEvent) => { if (!miniMapContainer.value || !overviewViewer.value) return; const rect = miniMapContainer.value.getBoundingClientRect(); const x = event.clientX - rect.left; const y = event.clientY - rect.top; // 计算在固定范围内的相对位置 const xPercent = (x / rect.width) * 100; const yPercent = (y / rect.height) * 100; // 转换为株洲市范围内的经纬度 const lon = ZHUZHOU_EXTENT.west + (xPercent / 100) * (ZHUZHOU_EXTENT.east - ZHUZHOU_EXTENT.west); const lat = ZHUZHOU_EXTENT.north - (yPercent / 100) * (ZHUZHOU_EXTENT.north - ZHUZHOU_EXTENT.south); // 主地图飞向点击位置 $prototype.$map.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(lon, lat, 1000000), }); }; function addImage() { var rightImageProvider = new Cesium.UrlTemplateImageryProvider({ name: "影像图", type: "xyz", layer: "vec_d", url: "http://124.232.190.30:9000/proxy/pk1725866655224/map/zzzsyx_18/{z}/{x}/{y}.png", minimumLevel: 1, maximumLevel: 17, crs: "EPSG:3857", }); $prototype.$map.imageryLayers.addImageryProvider(rightImageProvider); rightImageProvider.splitDirection = Cesium.SplitDirection.right; } onMounted(() => { initMap(); addImage(); loaded.value = true; addDemoGraphics(); flyToDes(); // 修复7:确保鹰眼地图完全初始化后再设置相机监听 setTimeout(() => { initMiniMap(); setupCameraListener(); // 初始更新 updateOverview(); }, 1000); (async () => { try { const ripplePoints = await loadRipplePoints(); rippleEntities.value = createMultipleRippleCircles( $prototype.$map, ripplePoints ); $prototype.$map.camera.changed.addEventListener(updateRippleVisibility); updateRippleVisibility(); } catch (error) { console.error('加载波纹圆失败:', error); } })(); }); let currentMarker: any = null; const createMarker = (location: { lng: number; lat: number; name: string }) => { if (currentMarker) { $prototype.$map.entities.remove(currentMarker); } currentMarker = $prototype.$map.entities.add({ position: Cesium.Cartesian3.fromDegrees( location.lng, location.lat, 50 ), point: { pixelSize: 200, color: Cesium.Color.RED, outlineColor: Cesium.Color.WHITE, outlineWidth: 2, heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND, }, label: { text: location.name, font: "40px sans-serif", fillColor: Cesium.Color.WHITE, outlineColor: Cesium.Color.BLACK, outlineWidth: 1, verticalOrigin: Cesium.VerticalOrigin.BOTTOM, pixelOffset: new Cesium.Cartesian2(0, -20), heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND, distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 10000), }, description: ${location.name} 经度:${location.lng.toFixed(6)} 纬度:${location.lat.toFixed(6)} , }); return currentMarker; }; const handleLocationSelected = (location: { lng: number; lat: number; name: string; }) => { if (!$prototype.$map) return; const destination = Cesium.Cartesian3.fromDegrees( location.lng, location.lat, 200 ); $prototype.$map.camera.flyTo({ destination, orientation: { heading: Cesium.Math.toRadians(0), pitch: Cesium.Math.toRadians(-45), roll: 0, }, duration: 2, complete: () => { createMarker(location); }, }); }; onUnmounted(() => { if ($prototype.$map) { $prototype.$map.destroy(); $prototype.$map = null; } if ($prototype.$map) { $prototype.$map.camera.changed.removeEventListener(updateRippleVisibility); } console.log("组件销毁"); }); const emit = defineEmits(["onload", "onclick"]); const initMars3d = async (option: any) => { emit("onclick", true); emit("onload", $prototype.$map); }; </script> <style lang="less"> /**cesium 工具按钮栏*/ .cesium-viewer-toolbar { top: auto !important; bottom: 35px !important; left: 12px !important; right: auto !important; } .cesium-toolbar-button img { height: 100%; } .cesium-viewer-toolbar > .cesium-toolbar-button, .cesium-navigationHelpButton-wrapper, .cesium-viewer-geocoderContainer { margin-bottom: 5px; float: left; clear: both; text-align: center; } .cesium-button { background-color: rgba(23, 49, 71, 0.8); color: #e6e6e6; fill: #e6e6e6; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); line-height: 32px; } .cesium-button:hover { background: #3ea6ff; } /**cesium 底图切换面板*/ .cesium-baseLayerPicker-dropDown { bottom: 0; left: 40px; max-height: 700px; margin-bottom: 5px; background-color: rgba(23, 49, 71, 0.8); } /**cesium 帮助面板*/ .cesium-navigation-help { top: auto; bottom: 0; left: 40px; transform-origin: left bottom; background: none; background-color: rgba(23, 49, 71, 0.8); .cesium-navigation-help-instructions { background: none; } .cesium-navigation-button { background: none; } .cesium-navigation-button-selected, .cesium-navigation-button-unselected:hover { background: rgba(0, 138, 255, 0.2); } } /**cesium 二维三维切换*/ .cesium-sceneModePicker-wrapper { width: auto; } .cesium-sceneModePicker-wrapper .cesium-sceneModePicker-dropDown-icon { float: right; margin: 0 3px; } /**cesium POI查询输入框*/ .cesium-viewer-geocoderContainer .search-results { left: 0; right: 40px; width: auto; z-index: 9999; } .cesium-geocoder-searchButton { background-color: rgba(23, 49, 71, 0.8); } .cesium-viewer-geocoderContainer .cesium-geocoder-input { background-color: rgba(63, 72, 84, 0.7); } .cesium-viewer-geocoderContainer .cesium-geocoder-input:focus { background-color: rgba(63, 72, 84, 0.9); } .cesium-viewer-geocoderContainer .search-results { background-color: rgba(23, 49, 71, 0.8); } /**cesium info信息框*/ .cesium-infoBox { top: 50px; background-color: rgba(23, 49, 71, 0.8); } .cesium-infoBox-title { background-color: rgba(23, 49, 71, 0.8); } /**cesium 任务栏的FPS信息*/ .cesium-performanceDisplay-defaultContainer { top: auto; bottom: 35px; right: 50px; } .cesium-performanceDisplay-ms, .cesium-performanceDisplay-fps { color: #fff; } /**cesium tileset调试信息面板*/ .cesium-viewer-cesiumInspectorContainer { top: 10px; left: 10px; right: auto; } .cesium-cesiumInspector { background-color: rgba(23, 49, 71, 0.8); } /**覆盖mars3d内部控件的颜色等样式*/ .mars3d-compass .mars3d-compass-outer { fill: rgba(23, 49, 71, 0.8); } .mars3d-contextmenu-ul, .mars3d-sub-menu { background-color: rgba(23, 49, 71, 0.8); > li > a:hover, > li > a:focus, > li > .active { background-color: #3ea6ff; } > .active > a, > .active > a:hover, > .active > a:focus { background-color: #3ea6ff; } } /* Popup样式*/ .mars3d-popup-color { color: #ffffff; } .mars3d-popup-background { background: rgba(23, 49, 71, 0.8); } .mars3d-popup-content { margin: 15px; } .mars3d-template-content label { padding-right: 6px; } .mars3d-template-titile { border-bottom: 1px solid #3ea6ff; } .mars3d-template-titile a { font-size: 16px; } .mars3d-tooltip { background: rgba(23, 49, 71, 0.8); border: 1px solid rgba(23, 49, 71, 0.8); } .mars3d-popup-btn-custom { padding: 3px 10px; border: 1px solid #209ffd; background: #209ffd1c; } .mars-dialog .mars-dialog__content { height: 100%; width: 100%; overflow: auto; padding: 5px; } .image { border: solid 2px #fff; } .content { height: 90%; padding-top: 10px; overflow-x: auto; overflow-y: auto; } .content-text { padding: 0 10px; text-indent: 30px; font-size: 17px; } .details-video { width: 100%; height: 760px; background-color: #000; } :where(.css-lt97qq9).ant-space { display: inline-flex; } :where(.css-lt97qq9).ant-space-align-center { align-items: center; } :where(.css-lt97qq9).ant-image .ant-image-mask { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; background: rgba(0, 0, 0, 0.5); cursor: pointer; opacity: 0; transition: opacity 0.3s; } :where(.css-lt97qq9).ant-image .ant-image-mask .ant-image-mask-info { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 4px; } :where(.css-1t97qq9)[class^="ant-image"] [class^="ant-image"], :where(.css-1t97qq9)[class*=" ant-image"] [class^="ant-image"], :where(.css-1t97qq9)[class^="ant-image"] [class*=" ant-image"], :where(.css-1t97qq9)[class*=" ant-image"] [class*=" ant-image"] { box-sizing: border-box; } :where(.css-lt97qq9).ant-image .ant-image-img { width: 100%; height: auto; vertical-align: middle; } </style> <style scoped> .mini-map-container { position: relative; width: 100%; height: 100%; } .main-viewer { width: 100%; height: 100%; } .mini-map { position: absolute; right: 3vw; bottom: 6vh; width: 12vw; height: 17vh; border: 2px solid #fff; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); z-index: 999; cursor: pointer; overflow: hidden; } .location-indicator { position: absolute; width: 14px; height: 14px; background: #ff3e3e; border: 2px solid white; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 15px rgba(255, 62, 62, 1); z-index: 100; } .view-rectangle { position: absolute; border: 2px solid #00f2fe; z-index: 99; pointer-events: none; box-shadow: 0 0 20px rgba(0, 242, 254, 0.7); } /* 相机聚焦样式 - 四个角折角 */ .corner { position: absolute; width: 25px; height: 25px; z-index: 100; pointer-events: none; } .corner::before, .corner::after { content: ""; position: absolute; background: #00f2fe; box-shadow: 0 0 10px rgba(0, 242, 254, 0.8); } .corner-top-left { top: -2px; left: -2px; } .corner-top-left::before { top: 0; left: 0; width: 15px; height: 3px; } .corner-top-left::after { top: 0; left: 0; width: 3px; height: 15px; } .corner-top-right { top: -2px; right: -2px; } .corner-top-right::before { top: 0; right: 0; width: 15px; height: 3px; } .corner-top-right::after { top: 0; right: 0; width: 3px; height: 15px; } .corner-bottom-left { bottom: -2px; left: -2px; } .corner-bottom-left::before { bottom: 0; left: 0; width: 15px; height: 3px; } .corner-bottom-left::after { bottom: 0; left: 0; width: 3px; height: 15px; } .corner-bottom-right { bottom: -2px; right: -2px; } .corner-bottom-right::before { bottom: 0; right: 0; width: 15px; height: 3px; } .corner-bottom-right::after { bottom: 0; right: 0; width: 3px; height: 15px; } .camera-icon { position: absolute; top: 10px; right: 10px; color: #00f2fe; font-size: 24px; z-index: 100; text-shadow: 0 0 10px rgba(0, 242, 254, 0.8); } .focus-effect { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 98; border: 2px solid rgba(0, 242, 254, 0.2); border-radius: 5px; box-shadow: inset 0 0 30px rgba(0, 242, 254, 0.1); } .pulse { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 10px; height: 10px; border-radius: 50%; background: rgba(0, 242, 254, 0.7); box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.7); animation: pulse 2s infinite; } ::v-deep.cesium-viewer-toolbar { display: none; } </style>

Map.vue:83 初始化主地图失败: TypeError: Cesium.WorldTerrain is not a constructor at initMainMap (Map.vue:50:24) at Map.vue:199:3 at runtime-core.esm-bundler.js:2836:40 at callWithErrorHandling (runtime-core.esm-bundler.js:199:19) at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:206:17) at hook.__weh.hook.__weh (runtime-core.esm-bundler.js:2816:19) at flushPostFlushCbs (runtime-core.esm-bundler.js:385:28) at render2 (runtime-core.esm-bundler.js:6048:7) at mount (runtime-core.esm-bundler.js:3962:13) at app.mount (runtime-dom.esm-bundler.js:1775:19) initMainMap @ Map.vue:83 (匿名) @ Map.vue:199 (匿名) @ runtime-core.esm-bundler.js:2836 callWithErrorHandling @ runtime-core.esm-bundler.js:199 callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:206 hook.__weh.hook.__weh @ runtime-core.esm-bundler.js:2816 flushPostFlushCbs @ runtime-core.esm-bundler.js:385 render2 @ runtime-core.esm-bundler.js:6048 mount @ runtime-core.esm-bundler.js:3962 app.mount @ runtime-dom.esm-bundler.js:1775 (匿名) @ main.ts:8 Map.vue:132 初始化鹰眼地图失败: TypeError: Cesium.RectanglePrimitive is not a constructor at initOverviewMap (Map.vue:122:32) at Map.vue:200:3 at runtime-core.esm-bundler.js:2836:40 at callWithErrorHandling (runtime-core.esm-bundler.js:199:19) at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:206:17) at hook.__weh.hook.__weh (runtime-core.esm-bundler.js:2816:19) at flushPostFlushCbs (runtime-core.esm-bundler.js:385:28) at render2 (runtime-core.esm-bundler.js:6048:7) at mount (runtime-core.esm-bundler.js:3962:13) at app.mount (runtime-dom.esm-bundler.js:1775:19) initOverviewMap @ Map.vue:132 (匿名) @ Map.vue:200 (匿名) @ runtime-core.esm-bundler.js:2836 callWithErrorHandling @ runtime-core.esm-bundler.js:199 callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:206 hook.__weh.hook.__weh @ runtime-core.esm-bundler.js:2816 flushPostFlushCbs @ runtime-core.esm-bundler.js:385 render2 @ runtime-core.esm-bundler.js:6048 mount @ runtime-core.esm-bundler.js:3962 app.mount @ runtime-dom.esm-bundler.js:1775 (匿名) @ main.ts:8 localhost/:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON at JSON.parse (<anonymous>) at Resource.js:1180:17 (匿名) @ Resource.js:1180 localhost/:1 Uncaught (in promise) SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON at JSON.parse (<anonymous>) at Resource.js:1180:17 如上所示报错,修改下面代码:<template> </template> <script setup lang="ts"> import { onMounted, onUnmounted, ref } from 'vue'; import * as Cesium from 'cesium'; import 'cesium/Build/Cesium/Widgets/widgets.css'; // 株洲市范围常量 const ZHUZHOU_EXTENT = new Cesium.Rectangle( Cesium.Math.toRadians(112.5), // west Cesium.Math.toRadians(26.0), // south Cesium.Math.toRadians(114.5), // east Cesium.Math.toRadians(28.0) // north ); // 地图实例引用 const mainViewer = ref<Cesium.Viewer | null>(null); const overviewViewer = ref<Cesium.Viewer | null>(null); const rectanglePrimitive = ref<Cesium.RectanglePrimitive | null>(null); // 初始化主地图 const initMainMap = async () => { try { // 设置Cesium访问令牌 Cesium.Ion.defaultAccessToken = "YOUR_CESIUM_ACCESS_TOKEN"; // 创建主地图实例 mainViewer.value = new Cesium.Viewer('cesiumContainer', { sceneMode: Cesium.SceneMode.SCENE3D, animation: false, baseLayerPicker: false, fullscreenButton: true, geocoder: false, homeButton: true, infoBox: false, sceneModePicker: true, selectionIndicator: true, timeline: false, navigationHelpButton: false, shouldAnimate: true, // 修复地形创建方式 terrainProvider: new Cesium.WorldTerrain({ requestVertexNormals: true, requestWaterMask: true }), imageryProvider: new Cesium.UrlTemplateImageryProvider({ url: "http://124.232.190.30:9000/proxy/pk1725866655224/map/zzzsyx_18/{z}/{x}/{y}.png", minimumLevel: 1, maximumLevel: 17 }) }); // 设置初始视图到株洲市范围 mainViewer.value.camera.flyTo({ destination: ZHUZHOU_EXTENT, orientation: { heading: Cesium.Math.toRadians(0), pitch: Cesium.Math.toRadians(-30), roll: 0.0 }, duration: 2.0 }); // 添加错误处理 mainViewer.value.scene.globe.tileLoadProgressEvent.addEventListener((pending) => { if (pending === 0) { console.log('所有瓦片加载完成'); } }); mainViewer.value.scene.error.addEventListener((error) => { console.error('Cesium错误:', error); }); } catch (error) { console.error('初始化主地图失败:', error); } }; // 初始化鹰眼地图 const initOverviewMap = () => { try { // 创建鹰眼地图实例 overviewViewer.value = new Cesium.Viewer('overviewMap', { sceneMode: Cesium.SceneMode.SCENE2D, baseLayerPicker: false, fullscreenButton: false, geocoder: false, homeButton: false, infoBox: false, sceneModePicker: false, selectionIndicator: false, timeline: false, navigationHelpButton: false, animation: false, imageryProvider: new Cesium.ArcGisMapServerImageryProvider({ url: 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer' }) }); // 隐藏不需要的控件 overviewViewer.value.cesiumWidget.creditContainer.style.display = "none"; // 设置鹰眼地图范围 overviewViewer.value.camera.setView({ destination: new Cesium.Rectangle( Cesium.Math.toRadians(110.0), // west Cesium.Math.toRadians(24.0), // south Cesium.Math.toRadians(116.0), // east Cesium.Math.toRadians(30.0) // north ) }); // 添加株洲市范围指示器 rectanglePrimitive.value = new Cesium.RectanglePrimitive({ rectangle: ZHUZHOU_EXTENT, material: Cesium.Color.RED.withAlpha(0.3), outline: true, outlineColor: Cesium.Color.RED, outlineWidth: 2 }); overviewViewer.value.scene.primitives.add(rectanglePrimitive.value); } catch (error) { console.error('初始化鹰眼地图失败:', error); } }; // 同步主地图和鹰眼地图 const syncMaps = () => { try { if (!mainViewer.value || !overviewViewer.value || !rectanglePrimitive.value) return; // 监听主地图相机变化 mainViewer.value.camera.changed.addEventListener(() => { const camera = mainViewer.value!.camera; // 计算当前视图范围 const rectangle = camera.computeViewRectangle(); if (rectangle) { // 更新鹰眼地图中的矩形 rectanglePrimitive.value!.rectangle = rectangle; // 更新鹰眼地图视角(如果矩形超出当前视图) const overviewCamera = overviewViewer.value!.camera; const overviewRectangle = overviewCamera.computeViewRectangle(); if (overviewRectangle && !Cesium.Rectangle.contains(overviewRectangle, rectangle)) { // 扩展矩形以包含当前视图 const expandedRect = new Cesium.Rectangle( Math.min(overviewRectangle.west, rectangle.west), Math.min(overviewRectangle.south, rectangle.south), Math.max(overviewRectangle.east, rectangle.east), Math.max(overviewRectangle.north, rectangle.north) ); overviewCamera.flyTo({ destination: expandedRect, duration: 0.5 }); } } }); // 鹰眼地图点击事件 overviewViewer.value.screenSpaceEventHandler.setInputAction((click: any) => { const position = click.position; const ray = overviewViewer.value!.camera.getPickRay(position); const cartesian = overviewViewer.value!.scene.globe.pick(ray, overviewViewer.value!.scene); if (cartesian) { // 主地图跳转到点击位置 mainViewer.value!.camera.flyTo({ destination: cartesian, orientation: { heading: mainViewer.value!.camera.heading, pitch: mainViewer.value!.camera.pitch, roll: 0.0 }, duration: 1.0 }); } }, Cesium.ScreenSpaceEventType.LEFT_CLICK); } catch (error) { console.error('地图同步失败:', error); } }; // 组件挂载时初始化地图 onMounted(() => { initMainMap(); initOverviewMap(); // 等待地图初始化完成后再同步 setTimeout(syncMaps, 1000); }); // 组件卸载时销毁地图实例 onUnmounted(() => { try { if (mainViewer.value) { mainViewer.value.destroy(); mainViewer.value = null; } if (overviewViewer.value) { overviewViewer.value.destroy(); overviewViewer.value = null; } } catch (error) { console.error('销毁地图实例失败:', error); } }); </script> <style> /* 全局重置样式 */ * { margin: 0; padding: 0; box-sizing: border-box; } html, body { width: 100%; height: 100%; overflow: hidden; /* 防止滚动条 */ font-family: sans-serif; } </style> <style scoped> .map-container { position: fixed; /* 使用 fixed 定位 */ top: 0; left: 0; width: 100%; height: 100%; /* 使用 100% 高度 */ overflow: hidden; /* 隐藏溢出内容 */ background-color: #1e1e1e; /* 深色背景防止白色间隙 */ } .main-map { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; } .overview-map { position: absolute; bottom: 20px; right: 20px; width: 300px; height: 200px; border: 2px solid #fff; box-shadow: 0 0 15px rgba(0, 0, 0, 0.7); z-index: 100; background-color: #000; /* 添加背景色 */ border-radius: 4px; /* 圆角 */ } /* 响应式调整 */ @media (max-width: 768px) { .overview-map { width: 150px; height: 100px; bottom: 10px; right: 10px; } } </style> 同时如图所示,顶部菜单栏的样式存在问题,蓝色部分太长了,都到了下面了,基于此修改代码发我

大家在看

recommend-type

蒙特卡罗剂量模拟和可视化工具包:一组旨在帮助临床医生和研究人员使用 GEANT4 或 TOPAS 的 Matlab 函数-matlab开发

这里有 3 组代码,旨在帮助临床医生和研究人员将 GEANT4 或 TOPAS (MC) 与 3D Slicer 结合使用进行剂量可视化和比较 第一段代码“STLfromDicomRN.m”采用 Varian Eclipse 生成的双散射质子计划的 Dicom 计划文件,并以“.STL”格式生成计划中的Kong径和补偿器模型。 此文件使用 zip 文件中包含的“stlwrite”和“surf2solid”函数。 这些文件可以导入到 MC 模拟几何中。 第二个是一组用于处理Dicom剂量文件和分析剂量的代码。 “NormalizeDicomDose.m”代码将 MC 剂量标准化为 Eclipse 剂量等中心处的剂量,并包含有关如何标准化为其他点或体积的说明。 “ProfilePlot.m”代码只是生成比较两点之间两个剂量文件的剂量的剂量曲线。 包含的是一个 matlab gui,它在您
recommend-type

中科大版苏淳概率论答案

本资料是中科大版本 苏淳编著的概率论答案,此为本书前半部分答案,其中包含书中部分习题,系老师所布置的重点习题答案。包含初等概率论,随机变量,随机向量,数字特征与特征函数极限定理几章的内容
recommend-type

公开公开公开公开-openprotocol_specification 2.7

LY-WCS-2012-01-06-01 V 1.0 公开公开公开公开 产品名称:产品名称:产品名称:产品名称: WCS 系统简介系统简介系统简介系统简介-公开版公开版公开版公开版 共共共共 13 页页页页 WCSWCSWCSWCS 系统简介系统简介系统简介系统简介 ((((客户交流用客户交流用客户交流用客户交流用)))) 文文文文 档档档档 作作作作 者:者:者:者: 王 超 日期:日期:日期:日期:2012/01/06 开发开发开发开发/测试经理:测试经理:测试经理:测试经理: 程 达 日期:日期:日期:日期:2012/01/06 项项项项 目目目目 经经经经 理:理:理:理: 程 达 日期:日期:日期:日期:2012/01/06 文文文文 档档档档 编编编编 号:号:号:号: ___________ ___ LY-WCS-2012-01-06-01______________ 上海朗因智能科技有限公司上海朗因智能科技有限公司上海朗因智能科技有限公司上海朗因智能科技有限公司 版权所有版权所有版权所有版权所有 不得复制不得复制不得复制不得复制
recommend-type

xilinx.com_user_IIC_AXI_1.0.zip

可以直接用在vivado 2017.4版本里。查看各个寄存器就知道用来干什么了,一号寄存器分频系数,二号的start、stop信号,三号寄存器8bit数据,四号寄存器只读,返回IIC状态和ACK信号,其中二号的一个bit可以用来不等待从机ACK,方便使用。
recommend-type

extjs6.2加SenchaCmd-6.5.3.6-windows-64bit

SenchaCmd-6.5.3.6-windows-64bit ext6.2.0gpl SenchaCmd-6.5.3.6-windows-64bit ext6.2.0gpl

最新推荐

recommend-type

员工工资管理系统VBSQL样本 (1)(1).doc

员工工资管理系统VBSQL样本 (1)(1).doc
recommend-type

门户网站建设方案(1).doc

门户网站建设方案(1).doc
recommend-type

计算机逻辑结构与基础课件4_2ALU的组织new(1).ppt

计算机逻辑结构与基础课件4_2ALU的组织new(1).ppt
recommend-type

化工自动化控制仪表作业试题..(1).doc

化工自动化控制仪表作业试题..(1).doc
recommend-type

模拟微信支付金额输入交互界面设计方案

资源下载链接为: https://pan.quark.cn/s/6e651c43a101 在 PayUI 的预览功能中,这个弹出层是基于 DialogFragment 实现的。所有相关逻辑都已封装在这个 DialogFragment 内部,因此使用起来十分便捷。 使用时,通过 InputCallBack 接口可以获取到用户输入的支付密码。你可以在该接口的回调方法中,发起请求来验证支付密码的正确性;当然,也可以选择在 PayFragment 内部直接修改密码验证的逻辑。 整个实现过程没有运用复杂高深的技术,代码结构清晰易懂,大家通过阅读代码就能轻松理解其实现原理和使用方法。
recommend-type

精选Java案例开发技巧集锦

从提供的文件信息中,我们可以看出,这是一份关于Java案例开发的集合。虽然没有具体的文件名称列表内容,但根据标题和描述,我们可以推断出这是一份包含了多个Java编程案例的开发集锦。下面我将详细说明与Java案例开发相关的一些知识点。 首先,Java案例开发涉及的知识点相当广泛,它不仅包括了Java语言的基础知识,还包括了面向对象编程思想、数据结构、算法、软件工程原理、设计模式以及特定的开发工具和环境等。 ### Java基础知识 - **Java语言特性**:Java是一种面向对象、解释执行、健壮性、安全性、平台无关性的高级编程语言。 - **数据类型**:Java中的数据类型包括基本数据类型(int、short、long、byte、float、double、boolean、char)和引用数据类型(类、接口、数组)。 - **控制结构**:包括if、else、switch、for、while、do-while等条件和循环控制结构。 - **数组和字符串**:Java数组的定义、初始化和多维数组的使用;字符串的创建、处理和String类的常用方法。 - **异常处理**:try、catch、finally以及throw和throws的使用,用以处理程序中的异常情况。 - **类和对象**:类的定义、对象的创建和使用,以及对象之间的交互。 - **继承和多态**:通过extends关键字实现类的继承,以及通过抽象类和接口实现多态。 ### 面向对象编程 - **封装、继承、多态**:是面向对象编程(OOP)的三大特征,也是Java编程中实现代码复用和模块化的主要手段。 - **抽象类和接口**:抽象类和接口的定义和使用,以及它们在实现多态中的不同应用场景。 ### Java高级特性 - **集合框架**:List、Set、Map等集合类的使用,以及迭代器和比较器的使用。 - **泛型编程**:泛型类、接口和方法的定义和使用,以及类型擦除和通配符的应用。 - **多线程和并发**:创建和管理线程的方法,synchronized和volatile关键字的使用,以及并发包中的类如Executor和ConcurrentMap的应用。 - **I/O流**:文件I/O、字节流、字符流、缓冲流、对象序列化的使用和原理。 - **网络编程**:基于Socket编程,使用java.net包下的类进行网络通信。 - **Java内存模型**:理解堆、栈、方法区等内存区域的作用以及垃圾回收机制。 ### Java开发工具和环境 - **集成开发环境(IDE)**:如Eclipse、IntelliJ IDEA等,它们提供了代码编辑、编译、调试等功能。 - **构建工具**:如Maven和Gradle,它们用于项目构建、依赖管理以及自动化构建过程。 - **版本控制工具**:如Git和SVN,用于代码的版本控制和团队协作。 ### 设计模式和软件工程原理 - **设计模式**:如单例、工厂、策略、观察者、装饰者等设计模式,在Java开发中如何应用这些模式来提高代码的可维护性和可扩展性。 - **软件工程原理**:包括软件开发流程、项目管理、代码审查、单元测试等。 ### 实际案例开发 - **项目结构和构建**:了解如何组织Java项目文件,合理使用包和模块化结构。 - **需求分析和设计**:明确项目需求,进行系统设计,如数据库设计、系统架构设计等。 - **代码编写和实现**:根据设计编写符合要求的代码,实现系统的各个模块功能。 - **测试和维护**:进行单元测试、集成测试,确保代码质量,对项目进行维护和升级。 ### 其他相关知识点 - **Java虚拟机(JVM)**:了解JVM的基本工作原理,包括类加载机制、内存管理、垃圾回收算法等。 - **常用Java框架**:比如Spring、Hibernate、MyBatis等,在实际开发中常常与Java基础结合使用,提高开发效率。 以上知识点可以作为学习Java案例开发的基础框架。在实际的开发实践中,开发者需要结合具体的项目需求,对这些知识点进行灵活运用。通过反复的案例实践,可以加深对Java编程的理解,并逐步提升开发技能。这份集锦可能包含的案例可能涉及上述知识点的具体应用,能够帮助学习者更好地理解理论与实践的结合,从而快速提升个人的Java开发能力。
recommend-type

【VASP报错深度解析】:5大技巧识别并永久解决离子距离太近警告

# 1. VASP软件简介及离子距离太近问题概述 ## 1.1 VASP软件简介 **VASP(Vienna Ab initio Simulation Package)** 是一款广泛应用于计算材料科学的软件,它基于密度泛函理论(DFT)计算固体、表面和分子的电子结构和性质。
recommend-type

npm error A complete log of this run can be found in: D:\Program Files\nodejs\node_cache\_logs\2025-04-20T15_11_51_454Z-debug-0.log

<think>好的,我需要帮助用户找到npm的错误调试日志位置,并解决他们遇到的npm错误。首先,用户已经提供了一个具体的日志路径:'D:\Program Files\nodejs\node_cache\_logs\2025-04-20T15_11_51_454Z-debug-0.log',但看起来这个路径可能有问题,因为日期是2025年,这可能是一个示例或输入错误。我需要确认正确的日志路径生成方式。 根据npm的默认配置,日志文件通常位于npm的缓存目录下的_logs文件夹中。默认情况下,Windows系统中npm的缓存路径是%AppData%\npm-cache,而日志文件会以当前日期和
recommend-type

深入理解内存技术文档详解

由于文件内容无法查看,仅能根据文件的标题、描述、标签以及文件名称列表来构建相关知识点。以下是对“内存详解”这一主题的详细知识点梳理。 内存,作为计算机硬件的重要组成部分,负责临时存放CPU处理的数据和指令。理解内存的工作原理、类型、性能参数等对优化计算机系统性能至关重要。本知识点将从以下几个方面来详细介绍内存: 1. 内存基础概念 内存(Random Access Memory,RAM)是易失性存储器,这意味着一旦断电,存储在其中的数据将会丢失。内存允许计算机临时存储正在执行的程序和数据,以便CPU可以快速访问这些信息。 2. 内存类型 - 动态随机存取存储器(DRAM):目前最常见的RAM类型,用于大多数个人电脑和服务器。 - 静态随机存取存储器(SRAM):速度较快,通常用作CPU缓存。 - 同步动态随机存取存储器(SDRAM):在时钟信号的同步下工作的DRAM。 - 双倍数据速率同步动态随机存取存储器(DDR SDRAM):在时钟周期的上升沿和下降沿传输数据,大幅提升了内存的传输速率。 3. 内存组成结构 - 存储单元:由存储位构成的最小数据存储单位。 - 地址总线:用于选择内存中的存储单元。 - 数据总线:用于传输数据。 - 控制总线:用于传输控制信号。 4. 内存性能参数 - 存储容量:通常用MB(兆字节)或GB(吉字节)表示,指的是内存能够存储多少数据。 - 内存时序:指的是内存从接受到请求到开始读取数据之间的时间间隔。 - 内存频率:通常以MHz或GHz为单位,是内存传输数据的速度。 - 内存带宽:数据传输速率,通常以字节/秒为单位,直接关联到内存频率和数据位宽。 5. 内存工作原理 内存基于电容器和晶体管的工作原理,电容器存储电荷来表示1或0的状态,晶体管则用于读取或写入数据。为了保持数据不丢失,动态内存需要定期刷新。 6. 内存插槽与安装 - 计算机主板上有专用的内存插槽,常见的有DDR2、DDR3、DDR4和DDR5等不同类型。 - 安装内存时需确保兼容性,并按照正确的方向插入内存条,避免物理损坏。 7. 内存测试与优化 - 测试:可以使用如MemTest86等工具测试内存的稳定性和故障。 - 优化:通过超频来提高内存频率,但必须确保稳定性,否则会导致数据损坏或系统崩溃。 8. 内存兼容性问题 不同内存条可能由于制造商、工作频率、时序、电压等参数的不匹配而产生兼容性问题。在升级或更换内存时,必须检查其与主板和现有系统的兼容性。 9. 内存条的常见品牌与型号 诸如金士顿(Kingston)、海盗船(Corsair)、三星(Samsung)和芝奇(G.Skill)等知名品牌提供多种型号的内存条,针对不同需求的用户。 由于“内存详解.doc”是文件标题指定的文件内容,我们可以预期在该文档中将详细涵盖以上知识点,并有可能包含更多的实践案例、故障排查方法以及内存技术的最新发展等高级内容。在实际工作中,理解并应用这些内存相关的知识点对于提高计算机性能、解决计算机故障有着不可估量的价值。
recommend-type

【机械特性分析进阶秘籍】:频域与时域对比的全面研究

# 1. 机械特性分析的频域与时域概述 ## 1.1 频域与时域分析的基本概念 机械特性分析是通