Added copy coords function
This commit is contained in:
@@ -602,6 +602,19 @@ map.on('moveend', () => {
|
||||
setupToURL()
|
||||
})
|
||||
|
||||
/**
|
||||
* Listener for querying a copy of the current coordinates
|
||||
*/
|
||||
window.addEventListener('on-copy-coords', () => {
|
||||
const lon = convertScaleToX(Number(localStorage.getItem('lastHeldXPosition')))
|
||||
const lat = convertScaleToY(Number(localStorage.getItem('lastHeldYPosition')))
|
||||
const coordsText = JSON.stringify({ x: lon, y: lat })
|
||||
|
||||
navigator.clipboard.writeText(coordsText)
|
||||
|
||||
window.dispatchEvent(new CustomEvent('on-toast-push', { bubbles: true, detail: { preset: 'copied-coords' }}))
|
||||
})
|
||||
|
||||
/**
|
||||
* UTILITIES
|
||||
*/
|
||||
@@ -609,7 +622,7 @@ map.on('moveend', () => {
|
||||
* Convert x coords to scale with ratio, zoom and offset
|
||||
* @param {number} x
|
||||
*/
|
||||
function convertXToScale(x) {
|
||||
function convertXToScale(x) {
|
||||
return (x * xRatio * zoomRatio) + xOffset
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user