adding more things from old site

This commit is contained in:
Chris Cochrun 2025-04-19 22:25:57 -05:00
parent 160891b85a
commit 8967915bd1
43 changed files with 1840 additions and 63 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

10
static/js/leaflet.extra-markers.min.js vendored Executable file

File diff suppressed because one or more lines are too long

108
static/js/leaflet.hugo.js Normal file
View file

@ -0,0 +1,108 @@
let leafletMapsObj = {};
let leafletMarkersObj = {};
function drawTrack(trackOpts, elevationOpts, markerOpts) {
var opts = {
elevationControl: {
options: {
position: elevationOpts.graphPosition,
theme: elevationOpts.graphTheme,
width: elevationOpts.graphWidth,
height: elevationOpts.graphHeight,
margins: {
top: 20,
right: 20,
bottom: 35,
left: 50
},
followMarker: elevationOpts.graphFollowMarker,
collapsed: elevationOpts.graphCollapsed,
detached: elevationOpts.graphDetached,
legend: false,
summary: false,
downloadLink: '',
gpxOptions: {
polyline_options: {
className: 'track-' + trackOpts.trackId + '-',
color: trackOpts.lineColor,
opacity: trackOpts.lineOpacity,
weight: trackOpts.lineWeight,
},
marker_options: {
startIcon: new L.ExtraMarkers.icon({
icon: markerOpts.iconStart,
markerColor: markerOpts.iconStartColor,
shape: markerOpts.iconStartShape,
prefix: 'fa',
extraClasses: markerOpts.iconStartClasses
}),
endIcon: new L.ExtraMarkers.icon({
icon: markerOpts.iconEnd,
markerColor: markerOpts.iconEndColor,
shape: markerOpts.iconEndShape,
prefix: 'fa',
extraClasses: markerOpts.iconEndClasses
}),
wptIcons: {
'': new L.ExtraMarkers.icon({
icon: markerOpts.icon,
markerColor: markerOpts.iconColor,
shape: markerOpts.iconShape,
prefix: 'fa',
extraClasses: markerOpts.iconClasses,
})
}
}
},
},
},
};
L.control.elevation(opts.elevationControl.options).addTo(leafletMapsObj[trackOpts.mapId]).load(trackOpts.trackPath);
/*map.on('eledata_loaded', function(e) {
track = e.track_info;
});*/
}
window.downloadFile = function (sUrl) {
//iOS devices do not support downloading. We have to inform user about this.
if (/(iP)/g.test(navigator.userAgent)) {
alert('Your device does not support files downloading. Please try again in desktop browser.');
return false;
}
//If in Chrome or Safari - download via virtual link click
if (window.downloadFile.isChrome || window.downloadFile.isSafari) {
//Creating new link node.
var link = document.createElement('a');
link.href = sUrl;
if (link.download !== undefined) {
//Set HTML5 download attribute. This will prevent file from opening if supported.
var fileName = sUrl.substring(sUrl.lastIndexOf('/') + 1, sUrl.length);
link.download = fileName;
}
//Dispatching click event.
if (document.createEvent) {
var e = document.createEvent('MouseEvents');
e.initEvent('click', true, true);
link.dispatchEvent(e);
return true;
}
}
// Force file download (whether supported by server).
if (sUrl.indexOf('?') === -1) {
sUrl += '?download';
}
window.open(sUrl, '_self');
return true;
};
window.downloadFile.isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
window.downloadFile.isSafari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;

41
static/js/map.js Normal file
View file

@ -0,0 +1,41 @@
function initMap() {
if ($('#map').length) {
let map_provider = $('#map-provider').val();
let lat = $('#map-lat').val();
let lng = $('#map-lng').val();
let zoom = parseInt($('#map-zoom').val());
let address = $('#map-dir').val();
let api_key = $('#map-api-key').val();
let map = new L.map('map').setView([lat, lng], zoom);
if (map_provider === 'mapbox' && api_key.length) {
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution:
'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
tileSize: 512,
maxZoom: 18,
zoomOffset: -1,
id: 'mapbox/streets-v11',
accessToken: api_key,
}).addTo(map);
} else {
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
}).addTo(map);
}
let marker = L.marker([lat, lng]).addTo(map);
let url = lat + ',' + lng + '#map=' + zoom + '/' + lat + '/' + lng + '&layers=N';
marker.bindPopup(
address +
'<p><a href="https://www.openstreetmap.org/directions?engine=osrm_car&route=' +
url +
'">Routing via OpenStreetMap</a></p>',
);
}
}
document.addEventListener('DOMContentLoaded', function () {
// Initialise street maps if necessary.
initMap();
});