feat: 跟随式导航(已走变灰 / 方向朝上 / 锁下方 / 偏航重算 / 拖动后返回导航)

前端实现(接口只提供折线与距离时间):
- 已走 / 剩余分段上色:按当前位置在折线上的投影切分,已走 #9E9E9E,
  剩余白描边 + #0A84FF 主线
- 行进方向朝上 + 当前位置压在屏幕下方约 74%:setHeading + setCenter + panBy;
  setHeading 不生效的环境(实测 headless WebGL 调完 getHeading 仍为 0)自动
  降级为「正北朝上」,只在控制台提示一次
- 偏航重算:离路线 >60 米触发 /api/nav_route 重算,12 秒冷却;
  阈值放宽是因为百度会把起点吸附到最近道路,和真实 GPS 天然差 20~50 米
- 拖动地图进入自由查看:显示「返回导航」胶囊,8 秒无操作自动回正
- 到达判定改用「到终点的真实距离 <25 米」,不再按进度比例(GPS 跳点会误判)
- 定位坐标系修正:navigator.geolocation 给的是 WGS84,先 wgs84->gcj02 再算投影,
  否则整体偏 500 米会一直判定偏航

UI:
- 导航信息条与后台「步行路线 AK」弹窗的 emoji 全部换成 inline SVG
- 新增「返回导航」胶囊样式
This commit is contained in:
zzy
2026-11-14 21:32:04 +08:00
parent bd147e9f4b
commit 75f040d90a
4 changed files with 348 additions and 77 deletions
+2 -2
View File
@@ -86,7 +86,7 @@ tr:hover{background:#3a3a3c}
<h1>🔧 管理后台</h1>
<div class="header-actions">
<button class="btn btn-primary" onclick="openTokenModal()">🔑 全局Token</button>
<button class="btn btn-gray" onclick="openRouteKeyModal()">🚶 步行路线 AK</button>
<button class="btn btn-gray" onclick="openRouteKeyModal()"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-right:4px"><circle cx="13" cy="4" r="2"/><path d="M11 21l1.5-6-3-2.5V8.5"/><path d="M12.5 12.5L16 15l1 4"/><path d="M8.5 8.5L6 11"/></svg>步行路线 AK</button>
<button class="btn btn-gray" onclick="openAlertConfig()">📢 告警邮箱</button>
<a href="/admin/logout" class="btn btn-sm btn-gray" style="text-decoration:none">退出</a>
</div>
@@ -922,7 +922,7 @@ async function saveToken(){
/* ============ 百度步行路线 AK/SK(服务端密钥) ============ */
async function openRouteKeyModal(){
openModal(`<h3>🚶 步行路线 AK/SK</h3>
openModal(`<h3><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-3px;margin-right:6px"><circle cx="13" cy="4" r="2"/><path d="M11 21l1.5-6-3-2.5V8.5"/><path d="M12.5 12.5L16 15l1 4"/><path d="M8.5 8.5L6 11"/></svg>步行路线 AK/SK</h3>
<p class="tip">卡片上的「步行 X 米 / 约 Y 分钟」用它算真实道路距离。<br>
需<b>服务端</b> AK + 已开通「步行路线规划(轻量)」;开了 SN 校验的要配套 SK。</p>
<div id="rk-loading" class="empty">加载中…</div>`);