Fixed numerous issues with unicode headers and filenames

This commit is contained in:
Vadim Likholetov 2023-12-11 17:12:12 +02:00
parent 6f1933aad1
commit 0e95c7706f
2 changed files with 60 additions and 13 deletions

View File

@ -35,4 +35,13 @@
.leaflet-container { .leaflet-container {
cursor: crosshair; cursor: crosshair;
} }
.circle-icon{
background: #f03;
border-radius: 50%;
color: white;
padding: 2px 4px;
text-align: center;
display: inline-block;
}
</style> </style>

View File

@ -62,7 +62,7 @@
<div id="map" class="mb-4"></div> <div id="map" class="mb-4"></div>
<div id="markers" class="mb-4"></div> <!-- New element for displaying marker coordinates -->
<!-- Display Comments --> <!-- Display Comments -->
{% for comment in sar.SARCall.comments %} {% for comment in sar.SARCall.comments %}
@ -314,13 +314,45 @@
.catch(error => console.error('Error loading GPX file:', error)); .catch(error => console.error('Error loading GPX file:', error));
} }
var coords = [];
function addMarker(e) {
// remove last marker if any
// markers.clearLayers();
// update circle count
circleCount++;
coords.push([e.latlng.lat.toFixed(5), e.latlng.lng.toFixed(5)]);
// create a new divIcon
var circleIcon = L.divIcon({
className: 'circle-icon',
html: circleCount,
iconSize: [15, 15]
});
// add new marker with custom icon
var marker = L.marker(e.latlng, {icon: circleIcon}).addTo(markers);
// update coordinates display
document.getElementById('markers').innerText = coords.join(' ');
// Create a temporary input to copy the text.
var tempInput = document.createElement('input');
document.body.appendChild(tempInput);
tempInput.value = coords.join(' ');
tempInput.select();
document.execCommand('copy');
document.body.removeChild(tempInput);
}
var gpxData = {{ gpx_ids | tojson }}; var gpxData = {{ gpx_ids | tojson }};
var map = L.map('map', var map = L.map('map',
{ {
fullscreenControl: true, fullscreenControl: true,
} }
).setView([{{ sar.SARCall.latitude }}, {{ sar.SARCall.longitude }}], 13); ).setView([{{ sar.SARCall.latitude }}, {{ sar.SARCall.longitude }}], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19, maxZoom: 19,
@ -335,20 +367,20 @@
// context menu // context menu
var markers = L.layerGroup().addTo(map);
var circleCount = 0;
var coordControl = L.control({position: 'bottomright'}); var coordControl = L.control({position: 'bottomright'});
map.on('contextmenu', function (e) { map.on('contextmenu', function (e) {
var coords = e.latlng.lat.toFixed(5) + ", " + e.latlng.lng.toFixed(5); var coords = e.latlng.lat.toFixed(5) + ", " + e.latlng.lng.toFixed(5);
// Create a temporary input to copy the text.
var tempInput = document.createElement('input');
document.body.appendChild(tempInput);
tempInput.value = coords;
tempInput.select();
document.execCommand('copy');
document.body.removeChild(tempInput);
coordControl.getContainer().innerHTML = "<strong>To clipboard: </strong> " + e.latlng.lat.toFixed(5) + ", " + e.latlng.lng.toFixed(5); coordControl.getContainer().innerHTML = "<strong>To clipboard: </strong> " + e.latlng.lat.toFixed(5) + ", " + e.latlng.lng.toFixed(5);
addMarker(e);
}); });
@ -365,7 +397,7 @@
polyline: true, polyline: true,
rectangle: false, rectangle: false,
circle: true, circle: true,
marker: true, marker: false,
}, },
}); });
map.addControl(drawControl); map.addControl(drawControl);
@ -383,7 +415,13 @@
coordControl.getContainer().innerHTML = " " + e.latlng.lat.toFixed(5) + ", " + e.latlng.lng.toFixed(5); coordControl.getContainer().innerHTML = " " + e.latlng.lat.toFixed(5) + ", " + e.latlng.lng.toFixed(5);
}); });
// remove all markers on left click and reset circle count
map.on('click', function () {
markers.clearLayers();
circleCount = 0;
document.getElementById('markers').innerText = "";
coords = [];
});
map.on('draw:created', function (e) { map.on('draw:created', function (e) {