Fixed apple maps logic
This commit is contained in:
parent
eba76a1ec4
commit
cc29527776
|
@ -9,26 +9,18 @@ import { Card, CardHeader, CardTitle, CardDescription, CardContent } from "@/com
|
||||||
|
|
||||||
export function Section() {
|
export function Section() {
|
||||||
const openMapsApp = () => {
|
const openMapsApp = () => {
|
||||||
// URL to the location on Google Maps
|
console.log('Button clicked!'); // Add this log to check if the function is being triggered
|
||||||
const googleMapsUrl = "https://maps.app.goo.gl/FQSY4ww5WZ9mATRP9";
|
|
||||||
// Default coordinates for opening on maps
|
|
||||||
const coordinates = "500 Broadway East, Little Falls, MN 56345";
|
const coordinates = "500 Broadway East, Little Falls, MN 56345";
|
||||||
|
|
||||||
// Check the platform (Android or iOS)
|
|
||||||
const userAgent = navigator.userAgent || navigator.vendor;
|
const userAgent = navigator.userAgent || navigator.vendor;
|
||||||
|
|
||||||
// For Android (Google Maps)
|
|
||||||
if (/android/i.test(userAgent)) {
|
if (/android/i.test(userAgent)) {
|
||||||
// Open Google Maps app using the deep link
|
|
||||||
window.location.href = `google.navigation:q=${coordinates}`;
|
window.location.href = `google.navigation:q=${coordinates}`;
|
||||||
}
|
} else if (/iPad|iPhone|iPod/.test(userAgent)) {
|
||||||
// For iOS (Apple Maps)
|
console.log('Opening Apple Maps...');
|
||||||
else if (/iPad|iPhone|iPod/.test(userAgent)) {
|
window.location.href = `https://maps.apple.com/?q=${encodeURIComponent(coordinates)}`;
|
||||||
// Open Apple Maps using the deep link
|
|
||||||
window.location.href = `maps:0,0?q=${coordinates}`;
|
|
||||||
} else {
|
} else {
|
||||||
// For other platforms, open Google Maps in the browser
|
window.open("https://maps.app.goo.gl/FQSY4ww5WZ9mATRP9", "_blank");
|
||||||
window.open(googleMapsUrl, "_blank");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue