修复苹果设备地址导航跳转

This commit is contained in:
Rei
2026-09-09 12:54:47 +08:00
parent b9376dfeec
commit 62fff755b3
+4 -1
View File
@@ -13,6 +13,7 @@ export default function Footer() {
// Desktop falls back to AMap's web search. On phones use the operating system's // Desktop falls back to AMap's web search. On phones use the operating system's
// map-navigation scheme so the user's installed/default map app handles the route. // map-navigation scheme so the user's installed/default map app handles the route.
const amapLink = `https://uri.amap.com/search?keyword=${encodeURIComponent(address)}&city=${encodeURIComponent('成都')}&view=map&src=ameiba` const amapLink = `https://uri.amap.com/search?keyword=${encodeURIComponent(address)}&city=${encodeURIComponent('成都')}&view=map&src=ameiba`
const appleMapsLink = `https://maps.apple.com/?daddr=${encodeURIComponent(address)}&dirflg=d`
const openNavigation = (event: MouseEvent<HTMLAnchorElement>) => { const openNavigation = (event: MouseEvent<HTMLAnchorElement>) => {
const ua = window.navigator.userAgent const ua = window.navigator.userAgent
const destination = encodeURIComponent(address) const destination = encodeURIComponent(address)
@@ -21,7 +22,9 @@ export default function Footer() {
window.location.href = `geo:0,0?q=${destination}` window.location.href = `geo:0,0?q=${destination}`
} else if (/iPhone|iPad|iPod/i.test(ua)) { } else if (/iPhone|iPad|iPod/i.test(ua)) {
event.preventDefault() event.preventDefault()
window.location.href = `maps://?q=${destination}` // Apple Maps Link is an HTTPS URL, which Safari and most iOS webviews
// handle more reliably than the blocked custom `maps://` scheme.
window.location.href = appleMapsLink
} }
} }
return ( return (