the-yard / index.html
toppshutter's picture
Add 2 files
7ffa99c verified
Raw History Blame Contribute Delete
14.7 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Saint Lucia Map with GPS</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg&callback=initMap&v=weekly" defer></script>
<style>
#map {
height: 500px;
}
.user-location-icon {
width: 20px;
height: 20px;
background-color: #3b82f6;
border-radius: 50%;
border: 3px solid white;
box-shadow: 0 0 10px rgba(0,0,0,0.3);
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { transform: scale(1); opacity: 1; }
50% { transform: scale(1.3); opacity: 0.7; }
100% { transform: scale(1); opacity: 1; }
}
.accuracy-circle {
fill: none;
stroke: #3b82f6;
stroke-width: 2;
stroke-opacity: 0.3;
fill-opacity: 0.1;
}
</style>
</head>
<body class="bg-gray-100">
<header class="bg-blue-600 text-white shadow-lg">
<div class="container mx-auto px-4 py-6">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="flex items-center mb-4 md:mb-0">
<i class="fas fa-map-marked-alt text-3xl mr-3"></i>
<h1 class="text-2xl font-bold">Saint Lucia Map</h1>
</div>
<div class="flex items-center space-x-4">
<button id="locate-btn" class="bg-blue-700 hover:bg-blue-800 text-white px-4 py-2 rounded-lg flex items-center">
<i class="fas fa-location-arrow mr-2"></i> Locate Me
</button>
</div>
</div>
</div>
</header>
<main class="container mx-auto px-4 py-8">
<div class="bg-white rounded-xl shadow-lg overflow-hidden mb-6">
<div id="map"></div>
</div>
<div class="bg-white rounded-xl shadow-lg p-6">
<h2 class="text-xl font-bold text-blue-600 mb-4 flex items-center">
<i class="fas fa-info-circle mr-2"></i> Location Information
</h2>
<div id="location-info" class="space-y-4">
<div class="text-center py-8 text-gray-500">
<i class="fas fa-map-marker-alt text-4xl mb-2"></i>
<p>Click "Locate Me" to find your position on the map</p>
</div>
</div>
</div>
</main>
<footer class="bg-gray-800 text-white py-6">
<div class="container mx-auto px-4">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="mb-4 md:mb-0">
<p>&copy; 2023 Saint Lucia Map Service. All rights reserved.</p>
</div>
<div class="flex space-x-4">
<a href="#" class="hover:text-blue-400"><i class="fab fa-twitter"></i></a>
<a href="#" class="hover:text-blue-400"><i class="fab fa-facebook"></i></a>
<a href="#" class="hover:text-blue-400"><i class="fab fa-instagram"></i></a>
</div>
</div>
</div>
</footer>
<script>
let map;
let userMarker;
let accuracyCircle;
const saintLuciaCenter = { lat: 13.9094, lng: -60.9789 }; // Center of Saint Lucia
function initMap() {
// Initialize the map centered on Saint Lucia
map = new google.maps.Map(document.getElementById("map"), {
center: saintLuciaCenter,
zoom: 11,
styles: [
{
featureType: "poi",
elementType: "labels",
stylers: [{ visibility: "off" }]
},
{
featureType: "transit",
elementType: "labels.icon",
stylers: [{ visibility: "off" }]
}
]
});
// Add some points of interest in Saint Lucia
addPointsOfInterest();
// Event listener for locate button
document.getElementById('locate-btn').addEventListener('click', locateUser);
}
function addPointsOfInterest() {
// Add markers for important locations in Saint Lucia
const locations = [
{
position: { lat: 14.0167, lng: -60.9833 },
title: "Castries",
icon: "https://maps.google.com/mapfiles/ms/icons/red-dot.png"
},
{
position: { lat: 14.0806, lng: -60.9522 },
title: "Gros Islet",
icon: "https://maps.google.com/mapfiles/ms/icons/blue-dot.png"
},
{
position: { lat: 13.8536, lng: -61.0667 },
title: "Soufrière",
icon: "https://maps.google.com/mapfiles/ms/icons/green-dot.png"
},
{
position: { lat: 13.7300, lng: -60.9500 },
title: "Vieux Fort",
icon: "https://maps.google.com/mapfiles/ms/icons/yellow-dot.png"
},
{
position: { lat: 13.9094, lng: -60.9789 },
title: "Pitons",
icon: "https://maps.google.com/mapfiles/ms/icons/purple-dot.png"
}
];
locations.forEach(location => {
new google.maps.Marker({
position: location.position,
map: map,
title: location.title,
icon: {
url: location.icon,
scaledSize: new google.maps.Size(32, 32)
}
});
});
}
function locateUser() {
const locationInfo = document.getElementById('location-info');
// Check if geolocation is available
if (navigator.geolocation) {
locationInfo.innerHTML = `
<div class="flex items-center justify-center py-4">
<i class="fas fa-spinner fa-spin text-2xl text-blue-600 mr-3"></i>
<span class="font-medium">Locating your position...</span>
</div>
`;
// Request current position
navigator.geolocation.getCurrentPosition(
position => {
// Success callback
showPosition(position);
},
error => {
// Error callback
showError(error);
},
{
enableHighAccuracy: true,
timeout: 10000,
maximumAge: 0
}
);
} else {
// Geolocation not supported
locationInfo.innerHTML = `
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4">
<div class="flex items-center">
<i class="fas fa-exclamation-circle mr-2"></i>
<p>Geolocation is not supported by your browser.</p>
</div>
</div>
`;
}
}
function showPosition(position) {
const locationInfo = document.getElementById('location-info');
const userLatLng = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
// Calculate distance from Saint Lucia center (for demo purposes)
const distance = calculateDistance(
userLatLng.lat, userLatLng.lng,
saintLuciaCenter.lat, saintLuciaCenter.lng
);
// Update location info panel
locationInfo.innerHTML = `
<div class="grid grid-cols-2 gap-4">
<div>
<p class="text-gray-600 font-medium">Latitude:</p>
<p class="font-mono">${userLatLng.lat.toFixed(6)}</p>
</div>
<div>
<p class="text-gray-600 font-medium">Longitude:</p>
<p class="font-mono">${userLatLng.lng.toFixed(6)}</p>
</div>
<div>
<p class="text-gray-600 font-medium">Accuracy:</p>
<p class="font-mono">${Math.round(position.coords.accuracy)} meters</p>
</div>
<div>
<p class="text-gray-600 font-medium">Distance from Center:</p>
<p class="font-mono">${distance.toFixed(2)} km</p>
</div>
</div>
<div class="mt-4">
<p class="text-sm text-gray-500">
<i class="fas fa-info-circle mr-1"></i>
Last updated: ${new Date().toLocaleTimeString()}
</p>
</div>
`;
// Remove previous marker and circle if they exist
if (userMarker) {
userMarker.setMap(null);
}
if (accuracyCircle) {
accuracyCircle.setMap(null);
}
// Add user location marker
userMarker = new google.maps.Marker({
position: userLatLng,
map: map,
title: "Your Location",
icon: {
path: google.maps.SymbolPath.CIRCLE,
fillColor: "#3b82f6",
fillOpacity: 1,
strokeColor: "white",
strokeWeight: 2,
scale: 10
},
animation: google.maps.Animation.DROP
});
// Add accuracy circle
accuracyCircle = new google.maps.Circle({
center: userLatLng,
radius: position.coords.accuracy,
map: map,
fillColor: "#3b82f6",
fillOpacity: 0.2,
strokeColor: "#3b82f6",
strokeOpacity: 0.5,
strokeWeight: 1
});
// Center map on user location
map.setCenter(userLatLng);
map.setZoom(15);
// Add info window
const infoWindow = new google.maps.InfoWindow({
content: `
<div class="font-medium">
<i class="fas fa-user-circle text-blue-600 mr-1"></i>
Your Location
</div>
<div class="text-sm mt-1">
Accuracy: ${Math.round(position.coords.accuracy)} meters
</div>
`
});
infoWindow.open(map, userMarker);
// Close info window after 5 seconds
setTimeout(() => {
infoWindow.close();
}, 5000);
}
function showError(error) {
const locationInfo = document.getElementById('location-info');
let errorMessage;
switch(error.code) {
case error.PERMISSION_DENIED:
errorMessage = "You denied the request for geolocation.";
break;
case error.POSITION_UNAVAILABLE:
errorMessage = "Location information is unavailable.";
break;
case error.TIMEOUT:
errorMessage = "The request to get your location timed out.";
break;
case error.UNKNOWN_ERROR:
errorMessage = "An unknown error occurred.";
break;
}
locationInfo.innerHTML = `
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4">
<div class="flex items-center">
<i class="fas fa-exclamation-circle mr-2"></i>
<p>${errorMessage}</p>
</div>
<div class="mt-2 text-sm">
<button onclick="locateUser()" class="text-blue-600 hover:text-blue-800 font-medium">
<i class="fas fa-redo mr-1"></i> Try Again
</button>
</div>
</div>
`;
}
// Helper function to calculate distance between two coordinates in km
function calculateDistance(lat1, lon1, lat2, lon2) {
const R = 6371; // Radius of the earth in km
const dLat = deg2rad(lat2 - lat1);
const dLon = deg2rad(lon2 - lon1);
const a =
Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
Math.sin(dLon/2) * Math.sin(dLon/2);
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
return R * c;
}
function deg2rad(deg) {
return deg * (Math.PI/180);
}
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=toppshutter/the-yard" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>