diff options
Diffstat (limited to 'src/MenuItem.mjs')
-rw-r--r-- | src/MenuItem.mjs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/MenuItem.mjs b/src/MenuItem.mjs index dbe984f..138b317 100644 --- a/src/MenuItem.mjs +++ b/src/MenuItem.mjs | |||
@@ -343,8 +343,30 @@ export const toggleMapFocus = map => | |||
343 | onclick: () => map.classList.toggle('focus') | 343 | onclick: () => map.classList.toggle('focus') |
344 | }) | 344 | }) |
345 | 345 | ||
346 | /** | ||
347 | * getCoordinatesByPixels. | ||
348 | * | ||
349 | * @param {HTMLElement} map instance | ||
350 | * @param {Number[]} xy -- pixel of window | ||
351 | */ | ||
346 | export const getCoordinatesByPixels = (map, xy) => | 352 | export const getCoordinatesByPixels = (map, xy) => |
347 | new Item({ | 353 | new Item({ |
348 | text: 'Get Coordinates', | 354 | text: 'Get Coordinates', |
349 | onclick: () => console.log(map.renderer.unproject(xy)) | 355 | onclick: () => { |
356 | const [x, y] = map.renderer.unproject(xy) | ||
357 | const xyString = `[${x.toFixed(7)}, ${y.toFixed(7)}]` | ||
358 | navigator.clipboard.writeText(xyString) | ||
359 | window.alert(`${xyString} copied to clipboard`) | ||
360 | } | ||
361 | }) | ||
362 | |||
363 | /** | ||
364 | * restoreCamera. | ||
365 | * | ||
366 | * @param {HTMLElement} map | ||
367 | */ | ||
368 | export const restoreCamera = map => | ||
369 | new Item({ | ||
370 | text: 'Restore Camera', | ||
371 | onclick: () => map.renderer.restoreCamera() | ||
350 | }) | 372 | }) |