Skip to content

Right-click context menu for maps

Choose a tag to compare

@github-actions github-actions released this 10 Nov 22:31
· 54 commits to main since this release

mapcontrol.js - addContextMenu(id, items, options): a right-click menu for GIS actions. It opens on right-click, a 0.5 s touch long-press (also on iPhone) or Menu/Shift+F10 on the focused map. items may be a function (position, feature) => [...] so the menu changes with what is under the pointer. Items support icons, disabled, danger, separators and submenus, plus built-ins "coordinates" (shows and copies lat, lng), "center", "zoom-in" and "zoom-out". Keyboard navigation, ARIA, dark mode, edge flipping and larger touch targets.

map.js - onMapContextMenu(id, fn) for building your own menu. The browser's menu is only suppressed while a listener exists, and never inside popups or controls. A tap followed by a long-press no longer zooms the map.

mapheat.js - addGridMap returns cellAt(position), for showing a cell's value in the context menu.