地图修改

This commit is contained in:
cwchen 2026-01-15 17:28:46 +08:00
parent d3ce652209
commit 46449ab8a1
2 changed files with 523 additions and 298 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 743 B

After

Width:  |  Height:  |  Size: 728 B

View File

@ -6,7 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script> <script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
<script type="text/javascript" src="https://api.map.baidu.com/api?v=3.0&&type=webgl&ak=iqyZkSZPurf61MhFV7hesbDukHdMBEEb"></script> <script type="text/javascript"
src="https://api.map.baidu.com/api?v=3.0&&type=webgl&ak=iqyZkSZPurf61MhFV7hesbDukHdMBEEb"></script>
<script type="text/javascript" src="https://api.map.baidu.com/library/Convertor/1.2/src/Convertor_min.js"></script> <script type="text/javascript" src="https://api.map.baidu.com/library/Convertor/1.2/src/Convertor_min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
// 确保Convertor库加载完成 // 确保Convertor库加载完成
@ -15,7 +16,7 @@
window.baiduMapConvertorReady = true; window.baiduMapConvertorReady = true;
} else { } else {
// 监听Convertor库加载 // 监听Convertor库加载
setTimeout(function() { setTimeout(function () {
if (typeof BMapGL !== 'undefined' && typeof BMapGL.Convertor !== 'undefined') { if (typeof BMapGL !== 'undefined' && typeof BMapGL.Convertor !== 'undefined') {
window.baiduMapConvertorReady = true; window.baiduMapConvertorReady = true;
} }
@ -25,26 +26,73 @@
<title>百度地图</title> <title>百度地图</title>
<style> <style>
body, html { margin: 0; padding: 0; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; } body,
html {
margin: 0;
padding: 0;
overflow: hidden;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
#map-container { width: 100vw; height: 100vh; position: relative; } #map-container {
width: 100vw;
height: 100vh;
position: relative;
/* --- 核心修复代码 START --- */
/* 1. 设置背景色:使用百度地图默认的陆地颜色(#F5F3F0 或 #FCF9F2)
这样即使瓦片没加载出来,用户看到的也是地图的底色,而不是刺眼的白屏闪烁 */
background-color: #F5F3F0;
/* 2. 开启硬件加速,减少渲染层重绘 */
transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
/* 3. 防止在某些 iOS 设备上出现灰色背景 */
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
/* --- 核心修复代码 END --- */
}
/* 4. 针对 WebGL 生成的 Canvas 元素进行优化 */
#map-container canvas {
/* 强制 GPU 合成 */
will-change: transform;
/* 避免图片渲染时的锯齿和闪动 */
image-rendering: -webkit-optimize-contrast;
}
/* 去除百度地图的水印和logo */ /* 去除百度地图的水印和logo */
.BMap_cpyCtrl, .anchorBL { display: none !important; } .BMap_cpyCtrl,
.anchorBL {
display: none !important;
}
/* 模型预览面板 */ /* 模型预览面板 */
.model-preview-panel { .model-preview-panel {
position: absolute; top: 0; left: 0; width: 100%; height: 100%; position: absolute;
z-index: 1000; display: flex; pointer-events: none; align-items: flex-start; top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1000;
display: flex;
pointer-events: none;
align-items: flex-start;
} }
.model-preview-tree { .model-preview-tree {
width: 300px; height: auto; max-height: 80vh; width: 300px;
height: auto;
max-height: 80vh;
margin: 5% 0 0 2%; margin: 5% 0 0 2%;
background: rgba(30, 30, 30, 0.85); /*稍微加深背景增加可读性*/ background: rgba(30, 30, 30, 0.85);
/*稍微加深背景增加可读性*/
border: 1px solid rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px; border-radius: 8px;
overflow-y: auto; overflow-x: hidden; overflow-y: auto;
overflow-x: hidden;
padding: 20px; padding: 20px;
pointer-events: auto; pointer-events: auto;
backdrop-filter: blur(5px); backdrop-filter: blur(5px);
@ -53,32 +101,85 @@
} }
/* 滚动条样式 */ /* 滚动条样式 */
.model-preview-tree::-webkit-scrollbar { width: 6px; } .model-preview-tree::-webkit-scrollbar {
.model-preview-tree::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 3px; } width: 6px;
.model-preview-tree::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.3); border-radius: 3px; } }
.model-preview-tree::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.5); }
.model-preview-tree::-webkit-scrollbar-track {
background: rgba(255, 255, 255, 0.05);
border-radius: 3px;
}
.model-preview-tree::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.3);
border-radius: 3px;
}
.model-preview-tree::-webkit-scrollbar-thumb:hover {
background: rgba(255, 255, 255, 0.5);
}
.tree-node {
margin-bottom: 2px;
}
.tree-node { margin-bottom: 2px; }
.tree-node-item { .tree-node-item {
display: flex; align-items: center; padding: 6px 8px; display: flex;
cursor: pointer; border-radius: 4px; transition: background-color 0.2s; align-items: center;
padding: 6px 8px;
cursor: pointer;
border-radius: 4px;
transition: background-color 0.2s;
min-height: 28px; min-height: 28px;
} }
.tree-node-item:hover { background-color: rgba(255, 255, 255, 0.1); }
.tree-node-checkbox { width: 16px; height: 16px; margin-right: 8px; cursor: pointer; accent-color: #002db6; } .tree-node-item:hover {
.tree-node-label { flex: 1; font-size: 14px; user-select: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } background-color: rgba(255, 255, 255, 0.1);
}
.tree-node-checkbox {
width: 16px;
height: 16px;
margin-right: 8px;
cursor: pointer;
accent-color: #002db6;
}
.tree-node-label {
flex: 1;
font-size: 14px;
user-select: none;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.tree-expand-icon { .tree-expand-icon {
display: inline-flex; align-items: center; justify-content: center; display: inline-flex;
width: 20px; height: 20px; margin-right: 4px; align-items: center;
cursor: pointer; transition: transform 0.2s; user-select: none; justify-content: center;
font-size: 12px; color: rgba(255, 255, 255, 0.7); width: 20px;
height: 20px;
margin-right: 4px;
cursor: pointer;
transition: transform 0.2s;
user-select: none;
font-size: 12px;
color: rgba(255, 255, 255, 0.7);
} }
.tree-expand-icon:hover { color: #fff; }
.tree-children { margin-top: 2px; display: none; } .tree-expand-icon:hover {
.tree-children.expanded { display: block; } color: #fff;
}
.tree-children {
margin-top: 2px;
display: none;
}
.tree-children.expanded {
display: block;
}
/* 全选/全不选按钮 */ /* 全选/全不选按钮 */
.tree-select-all { .tree-select-all {
@ -100,23 +201,34 @@
cursor: pointer; cursor: pointer;
transition: background-color 0.2s; transition: background-color 0.2s;
} }
.tree-select-btn:hover { .tree-select-btn:hover {
background: rgba(0, 45, 182, 1); background: rgba(0, 45, 182, 1);
} }
/* 工程列表面板 */ /* 工程列表面板 */
.project-list-panel { .project-list-panel {
position: absolute; top: 0; left: 0; width: 100%; height: 100%; position: absolute;
z-index: 999; display: flex; pointer-events: none; align-items: flex-start; top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 999;
display: flex;
pointer-events: none;
align-items: flex-start;
} }
.project-list-container { .project-list-container {
width: 300px; height: auto; max-height: 80vh; width: 300px;
height: auto;
max-height: 80vh;
margin: 5% 0 0 2%; margin: 5% 0 0 2%;
background: rgba(30, 30, 30, 0.85); background: rgba(30, 30, 30, 0.85);
border: 1px solid rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px; border-radius: 8px;
overflow-y: auto; overflow-x: hidden; overflow-y: auto;
overflow-x: hidden;
padding: 20px; padding: 20px;
pointer-events: auto; pointer-events: auto;
backdrop-filter: blur(5px); backdrop-filter: blur(5px);
@ -124,79 +236,152 @@
color: #fff; color: #fff;
} }
.project-list-container::-webkit-scrollbar { width: 6px; } .project-list-container::-webkit-scrollbar {
.project-list-container::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 3px; } width: 6px;
.project-list-container::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.3); border-radius: 3px; } }
.project-list-container::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.5); }
.project-list-container::-webkit-scrollbar-track {
background: rgba(255, 255, 255, 0.05);
border-radius: 3px;
}
.project-list-container::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.3);
border-radius: 3px;
}
.project-list-container::-webkit-scrollbar-thumb:hover {
background: rgba(255, 255, 255, 0.5);
}
.project-list-item { .project-list-item {
display: flex; align-items: center; padding: 6px 8px; display: flex;
cursor: pointer; border-radius: 4px; transition: background-color 0.2s; align-items: center;
min-height: 28px; margin-bottom: 2px; padding: 6px 8px;
cursor: pointer;
border-radius: 4px;
transition: background-color 0.2s;
min-height: 28px;
margin-bottom: 2px;
}
.project-list-item:hover {
background-color: rgba(255, 255, 255, 0.1);
} }
.project-list-item:hover { background-color: rgba(255, 255, 255, 0.1); }
.project-list-radio { .project-list-radio {
width: 16px; height: 16px; margin-right: 8px; cursor: pointer; width: 16px;
height: 16px;
margin-right: 8px;
cursor: pointer;
accent-color: #002db6; accent-color: #002db6;
} }
.project-list-label { .project-list-label {
flex: 1; font-size: 14px; user-select: none; flex: 1;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px;
user-select: none;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
} }
.project-list-enter-btn { .project-list-enter-btn {
padding: 4px 12px; font-size: 12px; background: rgba(0, 45, 182, 0.8); padding: 4px 12px;
color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 12px;
transition: background-color 0.2s; margin-left: 8px; background: rgba(0, 45, 182, 0.8);
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.2s;
margin-left: 8px;
}
.project-list-enter-btn:hover {
background: rgba(0, 45, 182, 1);
} }
.project-list-enter-btn:hover { background: rgba(0, 45, 182, 1); }
.model-preview-close { .model-preview-close {
position: absolute; top: 50px; right: 20px; position: absolute;
width: 40px; height: 40px; top: 50px;
right: 20px;
width: 40px;
height: 40px;
background: rgba(255, 255, 255, 0.95); background: rgba(255, 255, 255, 0.95);
border-radius: 50%; display: flex; align-items: center; justify-content: center; border-radius: 50%;
cursor: pointer; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); display: flex;
z-index: 1001; pointer-events: auto; align-items: center;
justify-content: center;
cursor: pointer;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
z-index: 1001;
pointer-events: auto;
} }
.model-preview-close::before, .model-preview-close::after {
content: ''; position: absolute; width: 2px; height: 20px; background: #333; .model-preview-close::before,
.model-preview-close::after {
content: '';
position: absolute;
width: 2px;
height: 20px;
background: #333;
transform: rotate(45deg); transform: rotate(45deg);
} }
.model-preview-close::after { transform: rotate(-45deg); }
.model-preview-close::after {
transform: rotate(-45deg);
}
/* AR 按钮 */ /* AR 按钮 */
.model-preview-ar { .model-preview-ar {
position: absolute; top: 100px; right: 20px; position: absolute;
width: 40px; height: 40px; top: 100px;
right: 20px;
width: 40px;
height: 40px;
background: rgba(0, 45, 182, 0.95); background: rgba(0, 45, 182, 0.95);
border-radius: 50%; display: flex; align-items: center; justify-content: center; border-radius: 50%;
cursor: pointer; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); display: flex;
z-index: 1001; pointer-events: auto; align-items: center;
justify-content: center;
cursor: pointer;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
z-index: 1001;
pointer-events: auto;
font-size: 20px; font-size: 20px;
color: #fff; color: #fff;
font-weight: bold; font-weight: bold;
} }
.model-preview-ar:hover { .model-preview-ar:hover {
background: rgba(0, 45, 182, 1); background: rgba(0, 45, 182, 1);
} }
/* 回到定位按钮 */ /* 回到定位按钮 */
.location-center-btn { .location-center-btn {
position: fixed; bottom: 20px; right: 20px; position: fixed;
width: 32px; height: 32px; bottom: 20px;
right: 20px;
width: 32px;
height: 32px;
background: rgba(255, 255, 255, 0.95) url('./image/position.png') center center / 70% no-repeat; background: rgba(255, 255, 255, 0.95) url('./image/position.png') center center / 70% no-repeat;
border-radius: 50%; display: flex; align-items: center; justify-content: center; border-radius: 50%;
cursor: pointer; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); display: flex;
z-index: 998; pointer-events: auto; align-items: center;
justify-content: center;
cursor: pointer;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
z-index: 998;
pointer-events: auto;
transition: transform 0.2s, box-shadow 0.2s; transition: transform 0.2s, box-shadow 0.2s;
} }
.location-center-btn:hover { .location-center-btn:hover {
transform: scale(1.1); transform: scale(1.1);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
} }
.location-center-btn:active { .location-center-btn:active {
transform: scale(0.95); transform: scale(0.95);
} }
@ -211,7 +396,8 @@
white-space: nowrap; white-space: nowrap;
font-size: 16px !important; font-size: 16px !important;
font-weight: bold !important; font-weight: bold !important;
text-shadow: 1px 1px 2px #fff, -1px -1px 2px #fff, 1px -1px 2px #fff, -1px 1px 2px #fff; /* 增加描边效果提升可见度 */ text-shadow: 1px 1px 2px #fff, -1px -1px 2px #fff, 1px -1px 2px #fff, -1px 1px 2px #fff;
/* 增加描边效果提升可见度 */
transform: translateX(-45%); transform: translateX(-45%);
} }
@ -221,24 +407,59 @@
border-radius: 12px; border-radius: 12px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
overflow: hidden; overflow: hidden;
display: flex; flex-direction: column; display: flex;
flex-direction: column;
backdrop-filter: blur(10px); backdrop-filter: blur(10px);
} }
.action-menu-item { .action-menu-item {
padding: 12px 16px; cursor: pointer; font-size: 14px; color: #333; padding: 12px 16px;
display: flex; align-items: center; border-bottom: 1px solid rgba(0,0,0,0.05); cursor: pointer;
font-size: 14px;
color: #333;
display: flex;
align-items: center;
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
transition: background 0.2s; transition: background 0.2s;
} }
.action-menu-item:last-child { border-bottom: none; }
.action-menu-item:hover { background: #f0f5ff; color: #002db6; } .action-menu-item:last-child {
.action-menu-item span { margin-right: 10px; font-size: 18px; } border-bottom: none;
}
.action-menu-item:hover {
background: #f0f5ff;
color: #002db6;
}
.action-menu-item span {
margin-right: 10px;
font-size: 18px;
}
/* 百度地图 InfoWindow 修正 */ /* 百度地图 InfoWindow 修正 */
.BMap_bubble_title { display: none; } .BMap_bubble_title {
.BMap_bubble_content { width: 100% !important; height: 100% !important; } display: none;
.BMap_pop > div { border-radius: 16px !important; border: 0 !important; } }
.BMap_pop > img { display: none; } /* 隐藏自带关闭按钮 */
.BMap_bubble_center { top: 0 !important; } .BMap_bubble_content {
width: 100% !important;
height: 100% !important;
}
.BMap_pop>div {
border-radius: 16px !important;
border: 0 !important;
}
.BMap_pop>img {
display: none;
}
/* 隐藏自带关闭按钮 */
.BMap_bubble_center {
top: 0 !important;
}
</style> </style>
</head> </head>
@ -509,7 +730,10 @@
}, },
initMap(projectInfo) { initMap(projectInfo) {
this.map = new BMapGL.Map('map-container'); this.map = new BMapGL.Map('map-container', {
enableHighResolution: true, // 开启高清适配
backgroundColor: [245, 243, 240, 255] // [R, G, B, A] 显式设置 GL 引擎的清屏颜色
})
const center = projectInfo[0] ? new BMapGL.Point(projectInfo[0].lng, projectInfo[0].lat) : new BMapGL.Point(116.404, 39.915); const center = projectInfo[0] ? new BMapGL.Point(projectInfo[0].lng, projectInfo[0].lat) : new BMapGL.Point(116.404, 39.915);
this.map.centerAndZoom(center, 12); this.map.centerAndZoom(center, 12);
this.map.enableScrollWheelZoom(true); this.map.enableScrollWheelZoom(true);
@ -1878,7 +2102,7 @@
*/ */
handleLocationError(error) { handleLocationError(error) {
let message = '定位失败: '; let message = '定位失败: ';
switch(error.code) { switch (error.code) {
case error.PERMISSION_DENIED: case error.PERMISSION_DENIED:
message += '用户拒绝了定位请求'; message += '用户拒绝了定位请求';
break; break;
@ -2555,7 +2779,7 @@
// 补丁:重写 renderTreeNode 以支持 UI 联动 // 补丁:重写 renderTreeNode 以支持 UI 联动
const _originalRender = App.renderTreeNode; const _originalRender = App.renderTreeNode;
App.renderTreeNode = function(node, container, level) { App.renderTreeNode = function (node, container, level) {
const nodeDiv = document.createElement('div'); const nodeDiv = document.createElement('div');
nodeDiv.className = 'tree-node'; nodeDiv.className = 'tree-node';
@ -2625,4 +2849,5 @@
window.onload = () => App.init(); window.onload = () => App.init();
} }
</script> </script>
</html> </html>