Class ContextMenuInvocationContext

java.lang.Object
io.jmix.mapsui.component.ContextMenuInvocationContext

public class ContextMenuInvocationContext extends Object
Class that holds details of the GeoMap's context menu invocation, which can be used to customize context menu before it is shown on the client-side.

Context menu can be configured in two levels:

  • GeoMap - a general context menu that applies to any place on the map.
  • Vector layer or Canvas Layer - a context menu that applies to geometries on the layer. Each layer can process context menu in its own way. Menu items added on the previous level are also included.

In order to customize context menu, define a contextMenuDelegate function for the GeoMap, VectorLayer or CanvasLayer. This can be done with handler mechanism in a screen controller, for example:

 @Install(to = "map", subject = "contextMenuDelegate")
 private ContextMenu mapContextMenuDelegate(final ContextMenuInvocationContext context) {
     ContextMenu contextMenu = context.getContextMenu();
     contextMenu.addItem("Center map here", selectedItem -> map.setCenter(
                     context.getPoint().getX(),
                     context.getPoint().getY()));
     return contextMenu;
 }
 
  • Method Details

    • create

      public static ContextMenuInvocationContext create(ContextMenu contextMenu)
    • getContextMenu

      public ContextMenu getContextMenu()
    • getPoint

      public org.locationtech.jts.geom.Point getPoint()
    • setPoint

      public void setPoint(org.locationtech.jts.geom.Point point)
    • getEntity

      public Object getEntity()
    • setEntity

      public void setEntity(Object entity)
    • getLayer

      public <T extends Layer> T getLayer()
    • setLayer

      public void setLayer(Layer layer)
    • getCanvasGeometry

      public CanvasLayer.Geometry getCanvasGeometry()
    • setCanvasGeometry

      public void setCanvasGeometry(CanvasLayer.Geometry canvasGeometry)
    • getClientX

      public int getClientX()
    • setClientX

      public void setClientX(int clientX)
    • getClientY

      public int getClientY()
    • setClientY

      public void setClientY(int clientY)