diff --git a/templates/index.html b/templates/index.html index 95c856a..d433678 100644 --- a/templates/index.html +++ b/templates/index.html @@ -48,6 +48,11 @@
+
+
+ + +

@@ -84,23 +89,35 @@ console.error("WebSocket error:", error); }; - var map = L.map('map'); + var map = L.map('map').setView([53.55, 10], 13); var tileLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors', maxZoom: 19 }).addTo(map); - if (navigator.geolocation) { - navigator.geolocation.getCurrentPosition(function(position) { - var lat = position.coords.latitude; - var lng = position.coords.longitude; - map.setView([lat, lng], 13); - }, function() { - map.setView([53.55, 10], 11); - }); - } else { - map.setView([53.55, 10], 11); - } + // Coordinate search functionality + document.getElementById('goToBtn').addEventListener('click', function() { + var input = document.getElementById('coord_search').value.trim(); + var parts = input.split(','); + if (parts.length === 2) { + var lat = parseFloat(parts[0].trim()); + var lng = parseFloat(parts[1].trim()); + if (!isNaN(lat) && !isNaN(lng) && lat >= -90 && lat <= 90 && lng >= -180 && lng <= 180) { + map.setView([lat, lng], 13); + } else { + alert('Invalid coordinates. Latitude must be -90 to 90, longitude must be -180 to 180.'); + } + } else { + alert('Please enter coordinates in format: lat, lng'); + } + }); + + document.getElementById('coord_search').addEventListener('keypress', function(e) { + if (e.key === 'Enter') { + e.preventDefault(); + document.getElementById('goToBtn').click(); + } + }); var drawnItems = new L.FeatureGroup(); map.addLayer(drawnItems); @@ -343,4 +360,4 @@ } - \ No newline at end of file +