cesium 点击label改变颜色

时间: 2025-08-29 15:51:04 AIGC 浏览: 253
虽然给定引用未直接提及在Cesium中点击label改变其颜色的方法,但可基于Cesium的常规开发思路分析实现方式。 在Cesium中,要实现点击label改变颜色,可借助事件监听器来捕获点击事件,之后修改对应label的颜色属性。以下是示例代码: ```javascript // 创建Cesium Viewer var viewer = new Cesium.Viewer('cesiumContainer'); // 创建一个label实体 var labelEntity = viewer.entities.add({ position: Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883), label: { text: 'Click me to change color', font: '14pt monospace', fillColor: Cesium.Color.WHITE, style: Cesium.LabelStyle.FILL_AND_OUTLINE, outlineWidth: 2, verticalOrigin: Cesium.VerticalOrigin.BOTTOM, pixelOffset: new Cesium.Cartesian2(0, -9) } }); // 添加点击事件监听器 var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas); handler.setInputAction(function (movement) { var pickedObject = viewer.scene.pick(movement.position); if (Cesium.defined(pickedObject) && pickedObject.id === labelEntity) { // 改变label的颜色 labelEntity.label.fillColor.setValue(Cesium.Color.RED); } }, Cesium.ScreenSpaceEventType.LEFT_CLICK); ``` 上述代码首先创建了一个Cesium Viewer,接着添加了一个label实体。然后,使用`Cesium.ScreenSpaceEventHandler`来监听左键点击事件。当点击label时,通过`viewer.scene.pick`方法获取被点击的对象,若该对象是之前创建的label实体,就将其颜色修改为红色。
阅读全文

相关推荐

An error occurred while rendering. Rendering has stopped. ReferenceError: shouldShow is not defined ReferenceError: shouldShow is not defined at http://localhost:8001/src/components/common-map/live-map.vue?t=1751774207331:38:23 at Proxy.forEach (<anonymous>) at http://localhost:8001/src/components/common-map/live-map.vue?t=1751774207331:37:28 at invokeFunc (http://localhost:8001/node_modules/.vite/deps/lodash.js?v=6636ce6c:3839:28) at leadingEdge (http://localhost:8001/node_modules/.vite/deps/lodash.js?v=6636ce6c:3845:30) at debounced (http://localhost:8001/node_modules/.vite/deps/lodash.js?v=6636ce6c:3887:24) at tD.raiseEvent (http://localhost:8001/libs/Cesium/Cesium.js:96:1282) at Jt._updateCameraChanged (http://localhost:8001/libs/Cesium/Cesium.js:11295:124016) at Xi.initializeFrame (http://localhost:8001/libs/Cesium/Cesium.js:12477:35438) at uC.render (http://localhost:8001/libs/Cesium/Cesium.js:12479:1576) 如图所示报错为什么 修改以下代码:<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; rippleEntities.value.forEach(entity => { entity.show = shouldShow; }); }, 200); // 每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; entity.show = false; }); }, 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(); // 添加视口矩形更新逻辑 if (viewIndicator) { viewIndicator.rectangle.coordinates = rectangle; } }; // 原有方法完全不变(初始化鹰眼地图) 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 cameraController = overviewViewer.value.scene.screenSpaceCameraController; cameraController.enableTranslate = false; cameraController.enableZoom = false; cameraController.enableRotate = false; cameraController.enableTilt = false; cameraController.enableLook = 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 = (wgsLocation) => { if (currentMarker) { $prototype.$map.entities.remove(currentMarker); } console.log("标记图片加载状态:", markerImage); console.log("创建标记位置:", wgsLocation); currentMarker = $prototype.$map.entities.add({ position: Cesium.Cartesian3.fromDegrees(wgsLocation.lng, wgsLocation.lat, 10), label: { text: wgsLocation.name + "(标记位置)", font: "18px sans-serif", fillColor: Cesium.Color.YELLOW, outlineColor: Cesium.Color.BLACK, outlineWidth: 2, verticalOrigin: Cesium.VerticalOrigin.TOP, pixelOffset: new Cesium.Cartesian2(0, 20), heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND, show: true, }, // 关键:用 billboard 替换 point billboard: { image: new URL("@/assets/images/building.png", import.meta.url).href, // 本地图标 width: 32, // 图标宽度(像素) height: 32, // 图标高度(像素) verticalOrigin: Cesium.VerticalOrigin.BOTTOM, // 让图标尖点对地 heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND, scale: 1.0, }, }); 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, 3000 ); $prototype.$map.camera.flyTo({ destination, orientation: { heading: Cesium.Math.toRadians(0), pitch: Cesium.Math.toRadians(-90), 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: 14px; height: 2px; } .location-indicator::after { width: 2px; height: 14px; } .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代码,其中为什么这个红色十字定位位置会不对,会呆在左上方,虽然移动后会变正确,但是刷新页面显示时就是有时候会不对,会影响观感,你阅读live-map.vue代码中鹰眼地图部分代码,尝试寻找原因修改,然后尽可能不更改其他任何无关代码,减少对代码的修改

// 1. 优化点位(Entity)配置,强制置顶 var point = window.viewer.entities.add({ name: data.ghName ? data.ghName : data.type == 0 && data.numData == 1 ? '顶点' : '点', position: data.position3, description: { position: data.position }, label: { // ... 其他配置不变 ... // 关键:禁用深度测试,确保标签不被任何物体遮挡 disableDepthTestDistance: Number.POSITIVE_INFINITY }, billboard: { // ... 其他配置不变 ... // 关键:禁用深度测试,确保图标不被任何物体遮挡 disableDepthTestDistance: Number.POSITIVE_INFINITY, // 额外添加:提升渲染优先级(Entity 内部生效) zIndex: 100 // 确保在其他 Entity 之上 } }); // 2. 优化圆形(Primitive)配置,确保不遮挡 Entity var primitives = new Cesium.Primitive({ geometryInstances: instance, appearance: new Cesium.MaterialAppearance({ material: new Cesium.Material({ fabric: { type: "Color", uniforms: { color: Cesium.Color.fromCssColorString("#2963C3").withAlpha(0.1) } } }), translucent: true, renderState: { depthTest: { enabled: false }, depthMask: false, // 关键:配置混合模式,让圆形正确与下层融合 blending: { enabled: true, equationRgb: Cesium.BlendingEquation.ADD, equationAlpha: Cesium.BlendingEquation.ADD, functionSourceRgb: Cesium.BlendingFunction.SOURCE_ALPHA, functionSourceAlpha: Cesium.BlendingFunction.SOURCE_ALPHA, functionDestinationRgb: Cesium.BlendingFunction.ONE_MINUS_SOURCE_ALPHA, functionDestinationAlpha: Cesium.BlendingFunction.ONE_MINUS_SOURCE_ALPHA } } }), show: true, allowPicking: false, zIndex: 1 }); // 3. 优化轮廓线(Primitive)配置 var primitivesLine = new Cesium.Primitive({ geometryInstances: polylineInstance, appearance: new Cesium.PolylineMaterialAppearance({ material: Cesium.Material.fromType("Color", { color: Cesium.Color.fromCssColorString("#2963C3").withAlpha(1) }), translucent: true, renderState: { depthTest: { enabled: false }, depthMask: false, // 同样添加混合模式 blending: { enabled: true, equationRgb: Cesium.BlendingEquation.ADD, equationAlpha: Cesium.BlendingEquation.ADD, functionSourceRgb: Cesium.BlendingFunction.SOURCE_ALPHA, functionSourceAlpha: Cesium.BlendingFunction.SOURCE_ALPHA, functionDestinationRgb: Cesium.BlendingFunction.ONE_MINUS_SOURCE_ALPHA, functionDestinationAlpha: Cesium.BlendingFunction.ONE_MINUS_SOURCE_ALPHA } } }), asynchronous: false, show: true, allowPicking: false, zIndex: 1 }); // 4. 确保圆形在点位之后添加到场景 // 先添加点位(Entity 会立即处理) routeArr.push(point); // 后添加圆形(Primitive 后添加,避免覆盖已添加的 Entity) this.circleEntity = window.viewer.scene.primitives.add(primitives); this.circleEntityOutline = window.viewer.scene.primitives.add(primitivesLine); 怎么确保的创建的点位在圆的上面呢

大家在看

recommend-type

密码::unlocked::sparkles::locked:创新,方便,安全的加密应用程序

隐身者 创新,方便,安全的加密应用程序。 加密无限位。 只记得一点。 Crypter是一款跨平台的加密应用程序,它使加密和解密变得很方便,同时仍然保持强大的安全性。 它解决了当今大多数安全系统中最弱的链接之一-弱密码。 它简化了安全密码的生成和管理,并且只需要记住一个位-MasterPass。 是一个加密应用程序,可以解密和加密包括文件和文件夹在内的任意数据。 该版本已发布,并针对macOS(OSX),Linux(适用于所有通过发行的发行版)和Windows(32和64位)进行了全面测试。 所有核心模块(提供核心功能的模块)都经过了全面测试。 会将MasterPass保存在操作系统的钥匙串中,因此您不必在每次打开应用程序时都输入它。 为了帮助加快开发速度,请发送PR剩下的内容做 如果您有任何建议,请打开一个问题,并通过PR进行改进! 还要签出 ( )一个分散的端到端加密消息传递应用程序。 链接到此自述文件: : 内容 安装 适用于所有主要平台的所有预构建二进制文件都可以在。 Crypter也适用于macOS的 。 因此,要安装它,只需在终端中运行以下命令:
recommend-type

基于强化学习的坦克大战python语言实现

该游戏有两个系统。一个是玩家控制的小车。还有一个AI控制的坦克可以自动探寻敌方坦克所在位置,进行攻击。 运行run_examples.py文件,可以实现坦克战斗界面,其中: machine_control() # human_control() 两个函数进行选择性注释,第一个为增强学习后的坦克大战。第二个函数 human_control()为认为操作进行坦克大战。 run_RF.py函数实现了增强学习模型训练过程。 坦克大战功能: 人工操作坦克控制功能 使用pygame库之后,可以检测玩家的控制,当玩家按下按键后,就可以映射到我方坦克上,从而进行操控。基本操作是: w——前进 s——后退 a——向左前进 d——向右前进 空格——发射导弹 Tensorflow(神经网络编程框架) 2.12 Keras(高级神经网络框架) 2.3.4
recommend-type

matlab自相关代码-Ecology-Discovery-via-Symbolic-Regression:通过符号回归揭示复杂生态动力学的代

matlab自相关代码通过符号回归进行生态发现 通过符号回归揭示复杂生态动力学的代码回购 陈以泽,Marco Tulio Angulo和Liu Yang-Yu 被BioEssays接受,2019(作为封面故事),第41卷,第12期 动机 了解复杂生态系统的动态是维持和控制它们的必要步骤。 然而,逆向工程生态系统动力学仍然具有挑战性,这主要是因为生态系统可能会采用非常广泛的动力学类别,这使得选择合适的模型结构来应用参数推论方法具有挑战性。 在这里,我们建议通过符号回归来缩小这种差距,这是一种机器学习方法,可以从时间数据中自动对模型结构和参数进行逆向工程。 关于发现的生态动力学的一些结果 在这里,我们显示了一些生成的样本以及样本的自相关 语言和依存关系 我们使用Matlab来实现该算法。 具体来说,我们使用开源Matlab包在符号回归算法中启用了多基因搜索。
recommend-type

CUDA编程学习(六份pdf)

之前一段时间迷上了用VsCode的markdown插件写笔记,就没怎么在csdn上写,全部生成pdf了,今天给传上去
recommend-type

IAU_SOFA_LIB

IAU子程序集 用于时间 岁差 章动 极移 等计算

最新推荐

recommend-type

大模型驱动的财务决策支持系统:架构设计与实证研究.docx

大模型驱动的财务决策支持系统:架构设计与实证研究.docx
recommend-type

P6快速部署自己的yolov509c++-tensorrt部署-linux

【P6】快速部署自己的yolov509c++-tensorrt部署_linux
recommend-type

AI生成物著作权:提供商责任与归属研究.docx

AI生成物著作权:提供商责任与归属研究.docx
recommend-type

基于Arduino的智能4x4键盘门锁系统设计与实现

在这个项目中,我们将构建一个基于Arduino UNO的无钥匙门锁系统,该系统将使用一个4x4键盘来输入密钥,并控制一个伺服电机以开启或关闭门锁。以下是对该项目中所使用到的关键技术点的详细解释: ### Arduino UNO和Genuino UNO Arduino UNO和Genuino UNO是开源电子原型平台,基于易于使用的硬件和软件。它们使用ATmega328P微控制器,并拥有众多扩展板和模块兼容,这使得它们在创建各种项目,包括无钥匙门锁系统时,成为非常流行的选项。 ### 4x4键盘输入 4x4键盘由4行4列共16个按键组成,常用的输入方式包括矩阵键盘扫描。在无钥匙门锁系统中,4x4键盘用于输入密码。每个按键按下时,都会产生一个唯一的信号,系统会根据这些信号来确定输入的密码。使用矩阵键盘扫描技术,Arduino可以通过少数几个引脚来检测每个按键的动作,这大大简化了硬件连接。 ### 伺服电机 伺服电机(Tower Pro MG996R)是该项目中的执行器,用于控制门锁的开关。伺服电机可以精确地控制角度,非常适合用来驱动门锁机械部分进行旋转操作。通过编程,Arduino可以向伺服电机发送脉冲信号,从而控制其转动到指定的位置,比如90度用于解锁,0度用于上锁。 ### 跳线和面包板 为了简化电路连接,跳线(通用)和面包板(通用)被用作临时的原型搭建工具。跳线允许模块间进行快速且可重配置的连接,而面包板则提供了一个方便的平台来组建电路,不需要焊接。 ### LED指示灯和蜂鸣器 5毫米LED灯(红色和黄色)以及蜂鸣器都是用于提供用户反馈的组件。红色LED可以指示门锁已锁定,而黄色LED可以指示门锁已被解锁。蜂鸣器用于当输入错误的密码时发出警报声,提示用户输入不正确。 ### Adafruit标准LCD Adafruit标准LCD - 16x2白色蓝色用于显示系统的状态信息,比如“输入密码”、“门已开”或“门已锁”等提示。16x2的LCD表示它有16个字符宽度和2行字符高度,非常适合显示简短的文本信息。 ### Blynk软件应用程序 Blynk是一个为物联网项目设计的手机应用,可以通过Wi-Fi或蓝牙连接到Arduino等微控制器。在这个项目中,Blynk可以用来远程控制门锁,允许用户通过手机应用程序来输入密码解锁门锁。 ### 安全性和加密 这个项目特别提到了安全性的问题,因此在设计上需要考虑密码的加密和存储。为了避免密码被轻易破解,应该使用一种加密算法来保护存储在系统中的密码。同时,还应考虑如何安全地传输密码,尤其是如果使用Blynk这样的远程控制方法。 ### 电路方案和编程 构建这样一个系统需要对Arduino进行编程,以便它可以读取4x4键盘输入的密码,并通过编程逻辑控制伺服电机。编程时,需要编写代码以实现以下功能: 1. 初始化所有硬件组件,包括键盘、LED灯、蜂鸣器和LCD显示屏。 2. 设置键盘扫描程序,以检测按键输入。 3. 检查输入的密码是否正确,通过与存储在代码中的正确密码进行比较。 4. 控制伺服电机解锁或上锁门锁。 5. 使用LED灯和蜂鸣器提供适当的用户反馈。 6. 如果使用Blynk,则需要编写与Blynk服务器通信的代码,以及处理远程输入的密码。 ### 项目文件说明 - `source_code.c`:包含Arduino项目的源代码,用于编程和控制整个系统。 - `FpB_saOmaPgP-e187qEVsYgrz8Qy.png`:可能是项目的原理图或演示图,用于展示电路连接和布局。 - `项目展示.rar`:一个压缩文件,可能包含项目相关的视频、图像或其他演示文件,用于展示项目的实际运行效果。 - `原文地址.txt`:包含指向项目详细说明、教程或发布源的链接,方便用户查看更多项目细节或下载资源。 这个项目结合了多种技术,从物理输入设备的控制到系统软件逻辑编程,再到用户界面的设计,是物联网和嵌入式系统学习的一个很好的实例。通过实施这个项目,可以加深对Arduino平台、外围硬件组件以及简单安全系统的理解。
recommend-type

深入探索TypeScript类型验证与状态管理

### 深入探索 TypeScript 类型验证与状态管理 #### 1. Redux 与 React 组件中的状态管理 在 React 应用中,Redux 是管理状态的强大工具。`useSelector` 是 Redux 提供的一个钩子,它接收两个 TypeScript 泛型参数:整个状态的类型和返回值的类型。通过使用 `useSelector`,我们可以将组件所需的数据限制在必要范围内。例如: ```typescript const state = useSelector<VenueState, VenueState>((state) => state) ``` 这里,直接返回了整个状态
recommend-type

trace切片怎么对齐

由于提供的引用内容未涉及trace切片对齐的方法相关信息,以下是一般情况下trace切片对齐的常见方法: ### 时间戳对齐 确定一个共同的时间基准,将不同trace切片的时间戳映射到该基准上。可以通过找到所有trace切片中最早的时间戳作为起始点,然后将其他时间戳减去这个起始时间,从而实现相对时间的对齐。 ```python import pandas as pd # 假设有两个trace切片,每个切片是一个包含时间戳和事件的DataFrame trace1 = pd.DataFrame({ 'timestamp': [100, 110, 120], 'event': [
recommend-type

Flink与Kafka实时数据充实流测试指南

根据给定的文件信息,我们将详细讨论以下知识点: 1. Apache Flink和Kafka在实时数据处理中的应用: Apache Flink是一个开源的流处理框架,用于在高吞吐量下进行有状态的计算。它特别适合实时数据处理场景,能够快速地处理无边界和有边界的数据流。Kafka是一个分布式流处理平台,主要用于构建实时数据管道和流应用程序。Flink与Kafka结合使用时,可以实现高效且可靠的数据摄入与处理流程,从而完成复杂的实时数据转换和分析任务。 2. 实时数据充实(Data Enrichment)概念: 数据充实是数据工程中的一个常见概念,指的是通过添加额外信息来增强数据的过程。在实时数据流处理中,数据充实通常用于为原始数据添加元数据、上下文信息或其他相关数据,以便对数据进行更全面的分析。例如,在零售行业中,通过实时数据充实,可以将销售数据与库存数据、价格信息等进行关联,从而获取更有价值的业务洞察。 3. 实践操作的先决条件和环境配置: - 在安装Flink之前,应确保系统满足最低硬件要求,即至少4GB可用内存。这是因为实时数据处理和流计算可能会占用较多计算资源,特别是内存资源。 - 存储库中包含的脚本和命令应在Linux或OS X操作系统上执行,这说明了Flink环境对操作系统有一定的要求,以确保最佳的运行效率和兼容性。 - 执行存储库中的脚本前需要确保脚本文件权限正确,即文件应设置为可执行(chmod +x ./start.sh)。这是基本的Linux系统操作,确保脚本文件具有正确的权限,以便能够被系统执行。 4. 本地环境的搭建与运行: - 提供了一个名为“start.sh”的脚本,用于本地环境的搭建和运行。执行此脚本后,需要在浏览器中输入指定的地址(http://localhost:8080和http://localhost:8081),以访问运行中的Flink和Kafka界面。这表明了如何在本地机器上快速搭建和启动一个实时数据处理和展示平台。 - Flink和Kafka的界面地址用于在研讨会期间展示相关数据处理结果,说明了如何利用这些工具的可视化特性来更好地理解和分析数据流处理过程。 5. 内容的表达方式和格式: - 该存储库中的内容主要通过名为“flink-kafka-workshop1”的笔记本进行表达。笔记本格式为一种方便记录和展示数据处理过程的方式,它通常包含一系列的代码、命令和注释,以便开发者更好地理解每一步的操作和结果。 - 笔记本的格式方便进行编码练习和知识分享,它使得实时数据处理的步骤和过程可视化,并且可以作为教学材料和学习资源。 6. Dockerfile的使用: 虽然给定文件中没有直接提及Dockerfile的内容,但根据标签可以推断,该存储库或相关环境可能涉及使用Docker容器技术。Dockerfile用于编写指令集,以自动化构建Docker镜像的过程。它通常包含了操作系统环境配置、依赖安装、服务部署等步骤,用于创建一个可以运行Flink和Kafka等应用程序的轻量级、可移植的容器环境。这说明了如何利用现代的容器化技术来简化大数据应用的部署和分发。 综上所述,该存储库涉及的知识点广泛,包括了实时数据处理、数据丰富、系统环境配置、本地运行环境搭建以及Docker容器技术的应用。通过实践操作,学习者可以深入理解Flink和Kafka在实时数据处理场景下的工作原理和应用方法。
recommend-type

前端应用中异步数据处理与获取的实践指南

### 前端应用中异步数据处理与获取的实践指南 在现代前端开发中,异步数据处理和获取是常见的需求。本文将介绍如何使用 JavaScript 的 `async/await` 语法简化异步操作,以及如何在 Stimulus 和 React 应用中实现数据的获取和更新。 #### 1. 异步操作与 `async/await` 在 JavaScript 中,处理多个异步操作时,传统的 `then` 链式调用可能会使代码变得复杂。例如: ```javascript updateData() { fetch("/sold_out_concerts").then((response) => {
recommend-type

ref,toRef,toRefs区别?

ref、toRef、toRefs都是Vue 3中用于创建响应式数据的方法,它们的区别如下: - **创建数据类型及响应式原理**:ref用于生成值类型的响应式数据,是对原始数据的拷贝,修改ref数据时,模板中的视图会改变,但原始数据不变。当修改ref的数据时,通过其`.value`属性进行操作,模板中的视图会相应更新,但原始数据不受影响。定义基础类型的响应式数据通常使用ref。例如: ```vue <template> <div>{{ num }}</div> </template> <script setup> import { ref } from 'vue'; let origin
recommend-type

OVER集成文档:虚拟传输与服务集成指南

在深入理解OVER集成文档之前,我们首先应该明确文档中所涉及的关键概念和技术组件。本篇文档主要介绍的是一个名为OVER的服务,其专注于虚拟传输和接收办公室服务相关的消息传递,并提供了一系列与之关联的操作功能。以下是对标题和描述中所蕴含知识点的详细阐述: 1. 集成文档简介 文档的简介部分提供了对OVER服务的总览。首先,它指出本文档旨在详细介绍与虚拟传输和接收办公室服务相关的消息传递内容。虚拟传输通常指的是在不同实体间通过网络进行的数据交换过程。接收办公室服务,则可能涉及到对数据的接收、存储、处理和分发的环节。 此外,简介中还提到,为了实现与OVER服务的集成,需要预先了解AOC联盟的PCI通用消息文档。这表明了文档使用者需要具备一定的前置知识,即对AOC联盟及其PCI标准有一定的认识,这是进行集成和后续操作的前提。 2. 可用的数据传输 文档进一步详细说明了通过OVER服务可以访问和操作的数据类型: - 发行人(Publisher):加泰罗尼亚开放行政联盟(Catalan Open Administration Alliance)是发布此服务的实体,表明了服务的官方来源和背书。 - 产品(Product):文档列出了几个核心的OVER相关产品,包括: - OVER_DOCUMENTATION:与特定流程关联的文档下载操作。 - OVER_FORMULARI:获取处理程序表单的操作,可能用于提交或查阅特定业务流程所需的表单。 - OVER_CONTEXT:获取过程上下文数据的操作,上下文数据可能包括与业务流程相关的各种环境变量或状态信息。 - OVER_PROCESSING:启动处理实例的操作,用于实例化业务流程的执行。 - OVER_UPDATE:允许向服务实例中分配信息的操作,如更新状态、文件编号和其他相关数据。 - OVER_CONSULT:提供查询功能,可以查询特定日期范围内的处理实例,这对于跟进和审计历史业务操作非常有帮助。 - OVER_LIST_FILES:列出基于关键参数或搜索执行的过程中的文件。这对于管理存储在服务中的文件数据是必要的,尤其在处理大量文档时能极大提升效率。 3. 文件名称列表 标题中提到的“OVER-main”很可能指的是包含在本集成文档中的主要文件或脚本。该文件可能是实现上述数据传输和操作功能的源代码、配置文件或其他重要资源。 总结以上内容,我们可以得知: - OVER服务是一个专注于虚拟传输和接收办公室业务流程的消息传递服务。 - 通过该服务,用户可以下载与流程相关的文档、获取和提交表单、管理处理实例、更新服务实例信息以及查询和列出相关文件。 - 在进行集成前,用户需要掌握AOC联盟的PCI通用消息标准的相关知识。 - “OVER-main”是本集成文档中所包含的核心文件或脚本,可能涉及到实际的服务部署或操作流程。 本集成文档为用户提供了详细的指导,帮助开发者或业务分析师理解如何使用OVER服务以及如何与其他系统进行集成,同时强调了遵循相关标准的重要性。