First commit
This commit is contained in:
37
app/web/static/main.js
Normal file
37
app/web/static/main.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// Center on a default point
|
||||
var map = L.map('map', { zoomControl: false }).setView([53.866237, 10.676289], 18);
|
||||
|
||||
// Add OSM tiles
|
||||
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
maxZoom: 19,
|
||||
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||
}).addTo(map);
|
||||
|
||||
var userIcon = L.icon({
|
||||
iconUrl: '/maps-arrow.svg', // Add a motorcycle icon to your static folder
|
||||
iconSize: [40, 40]
|
||||
});
|
||||
|
||||
// Get users location
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(function(position) {
|
||||
var lat = position.coords.latitude;
|
||||
var lon = position.coords.longitude;
|
||||
map.setView([lat, lon], 14);
|
||||
L.marker([lat, lon], {icon: userIcon}).addTo(map).bindPopup('You are here!');
|
||||
});
|
||||
}
|
||||
|
||||
// Custom Bootstrap zoom controls
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var zoomInBtn = document.getElementById('zoomInBtn');
|
||||
var zoomOutBtn = document.getElementById('zoomOutBtn');
|
||||
if (zoomInBtn && zoomOutBtn) {
|
||||
zoomInBtn.addEventListener('click', function() {
|
||||
map.zoomIn();
|
||||
});
|
||||
zoomOutBtn.addEventListener('click', function() {
|
||||
map.zoomOut();
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user