Shared Samples

GeoMedia Smart Client Workflow Manager provides tools for building and delivering highly-constrained, map-based workflows for the office or the field.
Showing results for 
Search instead for 
Do you mean 

Map Interaction

by Community Manager on ‎01-19-2016 02:35 AM - edited on ‎10-09-2019 04:04 AM by Technical Evangelist (1,055 Views)


The map interaction samples quickly show how you can interact with the map. The MapInteractionPlugin uses a selected element in the map to display the WKT representation of the selected element. The MousClickPlugin implements a listener that listens on mouse clicks on the map and displays the WKT representation of the clicked position.   

Bitbucket Link


The Map Interaction sample contains two plugins:

  • MapInteractionPlugin
  • MouseClickPlugin

The MapInteractionPlugin  extends the AbstractPlugin and offers two actions:

  • selectPrimitiveAndShowWKTDialog
  • captureGeometryAndShowWKTDialog

The selectPrimitiveAndShowWKTDialog action is only active in case that one layer is active and exactly one element in the map is selected (see Action configuration):


@Plugin(alias = "MapInteraction", vendor = "Hexagon Geospatial")
public class MapInteractionPlugin extends AbstractPlugin 
	@Action(actionLocation = ActionLocation.PLUGINTAB, activeRequired = true, minimumSelection = 1, maximumSelection = 1)
	public void selectPrimitiveAndShowWKTDialog() 
		MapSelectionCurator mapSelectionCurator = ApplicationContext.getBrowser().getMapSelectionCurator();
		GMap map = ApplicationContext.getBrowser().getMap();		
		Object[] selectedElementIds = mapSelectionCurator.getSelectedElements();
		GPrimitive[] selectedPrimitives = map.getElements(mapSelectionCurator.getActiveFeature().getUniqueId(), selectedElementIds);		
		DefaultDialog wktViewerDialog = new WKTViewerDialog(selectedPrimitives[0]);

Within the method, the selected primitive is used to show a new dialog containing the WKT representation of the selected primitive. 


The captureGeometryAndShowWKTDialog action starts a new GeometryCaptureInstance to capture a polygon and show the result of the captured primitive in a new dialog: 

@Action(actionLocation = ActionLocation.PLUGINTAB)
public void captureGeometryAndShowWKTDialog() 
	GeometryCaptureFactory.getCaptureInstance(GeometryCaptureType.Polygon, ApplicationContext.getBrowser().getMap(),
new IGeometryCaptureListener() { @Override public void captureFinished(GeometryCapture source) {}
@Override public void captureAborted(GeometryCapture source) {} @Override public void addCapturePrimitive(GeometryCapture source, GPrimitive... newPrimitives) { DefaultDialog wktViewerDialog = new WKTViewerDialog(newPrimitives[0]); wktViewerDialog.setVisible(true); } }).run(); }


The MouseClickPlugin adds a MouseListener to the map to log the point coordinates of the MouseEvent: 

@Plugin(alias="MouseClickPlugin", vendor="Hexagon Geospatial")
public class MouseClickPlugin extends AbstractPlugin
	public void start() throws Exception 
		ApplicationContext.getBrowser().getMap().addMouseListener(new MouseListener() {
			public void mouseReleased(MouseEvent e) {}
			public void mousePressed(MouseEvent e) {}
			public void mouseExited(MouseEvent e) {}
			public void mouseEntered(MouseEvent e) {}
			public void mouseClicked(MouseEvent e) {
				DefaultMapProducer mapProducer =  ApplicationContext.getBrowser().getMap().getMapProducer();				
				Log.getLogger().log(Level.FINE, String.format("X: %s | Y: %s ", mapProducer.toWorldX(e.getX()), mapProducer.toWorldY(e.getY())));