# Class MapMenu

Object
Window
PopupWindow
PopupControl
ContextMenu
MapMenu

All Implemented Interfaces:
  `Styleable`, `EventTarget`, `Skinnable`

public class MapMenu extends ContextMenu
A `ContextMenu` that can be shown in a `MapCanvas`. On construction, this menu is initially empty. Items can be added by the following method calls:

- `addReferenceSystems(RecentReferenceSystems)`:
  - Reference system with some items from EPSG database.
  - Centered projection with the list of `PositionableProjection` items.

More choices may be added in a future versions. In current implementation, there is no mechanism for removing menu items.

Since:
  1.1

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from class PopupControl

  `PopupControl​.CSSBridge`

  ### Nested classes/interfaces inherited from class PopupWindow

  `PopupWindow​.AnchorLocation`

- ## Property Summary

  ### Properties inherited from class ContextMenu

  `onAction`

  ### Properties inherited from class PopupControl

  `id, maxHeight, maxWidth, minHeight, minWidth, prefHeight, prefWidth, skin, style`

  ### Properties inherited from class PopupWindow

  `anchorLocation, anchorX, anchorY, autoFix, autoHide, consumeAutoHidingEvents, hideOnEscape, onAutoHide, ownerNode, ownerWindow`

  ### Properties inherited from class Window

  `eventDispatcher, focused, forceIntegerRenderScale, height, onCloseRequest, onHidden, onHiding, onShowing, onShown, opacity, outputScaleX, outputScaleY, renderScaleX, renderScaleY, scene, showing, width, x, y`

- ## Field Summary

  ### Fields inherited from class PopupControl

  `bridge, USE_COMPUTED_SIZE, USE_PREF_SIZE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MapMenu(MapCanvas canvas)`
  Creates an initially empty menu for the given canvas.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addCopyOptions(StatusBar format)`
  Adds a menu item for copying coordinates at the mouse position where right click occurred.
  `void`
  `addReferenceSystems(RecentReferenceSystems preferences)`
  Adds menu items for CRS selection.
  `Optional<ObservableObjectValue<String>>`
  `selectedReferenceSystem()`
  Returns an observable value for showing the currently selected CRS as a text.

  ### Methods inherited from class ContextMenu

  `createDefaultSkin, getItems, getOnAction, hide, onActionProperty, setOnAction, show, show`

  ### Methods inherited from class PopupControl

  `getClassCssMetaData, getCssMetaData, getId, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getPrefHeight, getPrefWidth, getPseudoClassStates, getSkin, getStyle, getStyleableNode, getStyleableParent, getStyleClass, getTypeSelector, idProperty, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, pseudoClassStateChanged, setId, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setPrefHeight, setPrefSize, setPrefWidth, setSkin, setStyle, skinProperty, styleProperty`

  ### Methods inherited from class PopupWindow

  `anchorLocationProperty, anchorXProperty, anchorYProperty, autoFixProperty, autoHideProperty, consumeAutoHidingEventsProperty, getAnchorLocation, getAnchorX, getAnchorY, getConsumeAutoHidingEvents, getOnAutoHide, getOwnerNode, getOwnerWindow, hideOnEscapeProperty, isAutoFix, isAutoHide, isHideOnEscape, onAutoHideProperty, ownerNodeProperty, ownerWindowProperty, setAnchorLocation, setAnchorX, setAnchorY, setAutoFix, setAutoHide, setConsumeAutoHidingEvents, setHideOnEscape, setOnAutoHide, setScene, show, show`

  ### Methods inherited from class Window

  `addEventFilter, addEventHandler, buildEventDispatchChain, centerOnScreen, eventDispatcherProperty, fireEvent, focusedProperty, forceIntegerRenderScaleProperty, getEventDispatcher, getHeight, getOnCloseRequest, getOnHidden, getOnHiding, getOnShowing, getOnShown, getOpacity, getOutputScaleX, getOutputScaleY, getProperties, getRenderScaleX, getRenderScaleY, getScene, getUserData, getWidth, getWindows, getX, getY, hasProperties, heightProperty, isFocused, isForceIntegerRenderScale, isShowing, onCloseRequestProperty, onHiddenProperty, onHidingProperty, onShowingProperty, onShownProperty, opacityProperty, outputScaleXProperty, outputScaleYProperty, removeEventFilter, removeEventHandler, renderScaleXProperty, renderScaleYProperty, requestFocus, sceneProperty, setEventDispatcher, setEventHandler, setForceIntegerRenderScale, setHeight, setOnCloseRequest, setOnHidden, setOnHiding, setOnShowing, setOnShown, setOpacity, setRenderScaleX, setRenderScaleY, setUserData, setWidth, setX, setY, show, showingProperty, sizeToScene, widthProperty, xProperty, yProperty`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MapMenu

    public MapMenu(MapCanvas canvas)
    Creates an initially empty menu for the given canvas.
    Parameters:
      `canvas` - the canvas for which to create menus.

- ## Method Details

  - ### addReferenceSystems

    public void addReferenceSystems(RecentReferenceSystems preferences)
    Adds menu items for CRS selection. The menu items are in two groups:
    - Reference system with some items from EPSG database.
    - Centered projection with the list of `PositionableProjection` items.
    This method can be invoked at most once.
    Parameters:
      `preferences` - handler of menu items for selecting a CRS from a list of EPSG codes. Often built from user preferences.
    Throws:
      `IllegalStateException` - if this method has already been invoked.
    See Also:
      - `selectedReferenceSystem()`

  - ### addCopyOptions

    public void addCopyOptions(StatusBar format)
    Adds a menu item for copying coordinates at the mouse position where right click occurred. The coordinate reference system is determined by the status bar; it is not necessarily the coordinate reference system of the map.
    Parameters:
      `format` - status bar determining the CRS and format to use for coordinate values.

  - ### selectedReferenceSystem

    public Optional<ObservableObjectValue<String>> selectedReferenceSystem()
    Returns an observable value for showing the currently selected CRS as a text. The value is absent if `addReferenceSystems(RecentReferenceSystems)` has never been invoked.
    Returns:
      the currently selected CRS as a text.
    See Also:
      - `addReferenceSystems(RecentReferenceSystems)`