Skip to content

Commit

Permalink
#626 Better Screenshot Filenames (#627)
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman authored Feb 12, 2025
1 parent 55cca23 commit 367b0d8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/essence/Basics/UserInterface_/BottomBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ let BottomBar = {
$('.leaflet-control-zoom').css('display', 'none')
$('#topBarScreenshotLoading').css('display', 'block')
$('#scaleBar').css('margin-top', '0px')
const savedMapToolBarBottom =
$('#mapToolBar').css('bottom') || '0px'
$('#mapToolBar').css('bottom', '0px')
$(`#toggleTimeUI.active`).trigger('click')

const documentElm = document.getElementById('mapScreen')
HTML2Canvas(documentElm, {
Expand Down Expand Up @@ -127,9 +131,18 @@ let BottomBar = {
}).then(function (canvas) {
canvas.id = 'mmgisScreenshot'
document.body.appendChild(canvas)

const mission = L_.configData?.msv?.mission
const time = L_.TimeControl_?.currentTime
const mapCenter = L_.Map_.map.getCenter()
const lng = mapCenter.lng.toFixed(4)
const lat = mapCenter.lat.toFixed(4)

F_.downloadCanvas(
canvas.id,
'mmgis-screenshot',
`mmgis-${mission}_${
time ? `${time.replaceAll(':', '-')}_` : ''
}${lat}_${lng}`,
function () {
canvas.remove()
setTimeout(function () {
Expand All @@ -150,6 +163,7 @@ let BottomBar = {
$('#mmgis-map-compass').css('display', 'block')
$('.leaflet-control-zoom').css('display', 'block')
$('#scaleBar').css('margin-top', '5px')
$('#mapToolBar').css('bottom', 'savedMapToolBarBottom')
})

tippy(`#topBarScreenshot`, {
Expand Down

0 comments on commit 367b0d8

Please sign in to comment.