修复苹果设备地址导航跳转
This commit is contained in:
@@ -13,6 +13,7 @@ export default function Footer() {
|
||||
// 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.
|
||||
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 ua = window.navigator.userAgent
|
||||
const destination = encodeURIComponent(address)
|
||||
@@ -21,7 +22,9 @@ export default function Footer() {
|
||||
window.location.href = `geo:0,0?q=${destination}`
|
||||
} else if (/iPhone|iPad|iPod/i.test(ua)) {
|
||||
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 (
|
||||
|
||||
Reference in New Issue
Block a user