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() {
|
||||
const openMapsApp = () => {
|
||||
// URL to the location on Google Maps
|
||||
const googleMapsUrl = "https://maps.app.goo.gl/FQSY4ww5WZ9mATRP9";
|
||||
// Default coordinates for opening on maps
|
||||
console.log('Button clicked!'); // Add this log to check if the function is being triggered
|
||||
const coordinates = "500 Broadway East, Little Falls, MN 56345";
|
||||
|
||||
// Check the platform (Android or iOS)
|
||||
const userAgent = navigator.userAgent || navigator.vendor;
|
||||
|
||||
// For Android (Google Maps)
|
||||
if (/android/i.test(userAgent)) {
|
||||
// Open Google Maps app using the deep link
|
||||
window.location.href = `google.navigation:q=${coordinates}`;
|
||||
}
|
||||
// For iOS (Apple Maps)
|
||||
else if (/iPad|iPhone|iPod/.test(userAgent)) {
|
||||
// Open Apple Maps using the deep link
|
||||
window.location.href = `maps:0,0?q=${coordinates}`;
|
||||
} else if (/iPad|iPhone|iPod/.test(userAgent)) {
|
||||
console.log('Opening Apple Maps...');
|
||||
window.location.href = `https://maps.apple.com/?q=${encodeURIComponent(coordinates)}`;
|
||||
} else {
|
||||
// For other platforms, open Google Maps in the browser
|
||||
window.open(googleMapsUrl, "_blank");
|
||||
window.open("https://maps.app.goo.gl/FQSY4ww5WZ9mATRP9", "_blank");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue