Created
November 9, 2022 19:08
-
-
Save tobimori/0378d6f2e395244acbe14ad925261559 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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