Skip to content

Instantly share code, notes, and snippets.

@tobimori
Created November 9, 2022 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobimori/0378d6f2e395244acbe14ad925261559 to your computer and use it in GitHub Desktop.
Save tobimori/0378d6f2e395244acbe14ad925261559 to your computer and use it in GitHub Desktop.
export const openRoute = (loc: { address: string; long: number; lat: number }) => {
trackEvent(['trackEvent', 'Shopstandorte', `Route geöffnet`, `Route zu ${loc.address}`])
if (/iPad|iPhone|iPod|Mac/.test(navigator.platform)) {
window.open(`http://maps.apple.com/?daddr=${encodeURIComponent(loc.address)}`)
} else if (/Android/.test(navigator.platform)) {
window.open(
`geo:${encodeURIComponent(loc.lat)},${encodeURIComponent(loc.long)}?q=${encodeURIComponent(
loc.address
)}`
)
} else {
window.open(
`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(loc.address)}`
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment