What about opening an editor screen for a geo-object, you can do it by subscribing to event of clicking on the geo-object (as described in this topic).
If none of these options is applicable for your case, could you please tell us about it in more detail?
Hi Gleb,
this is exactly what I was looking for!
But this works only when I right click on the map; I’d like to do the same on a geo-object (point/marker, polyline, polygon) both on a VectorLayer and on a CanvasLayer.
For example, when I do right click on a Point, I’d like to open a menu with this items:
Open Entity Screen
Open other Entity connected screens (maybe with a submenu?)
Move point (i.e. change coordinates by setting the Point editable)
Zoom here (already implemented)
Center Map here (already implemented)
Get geographic data (invoking OpenStreetMap nominatim service - already implemented)
View this Point on GoogleMaps (already implemented)
I tried to implement a context menu on a Point, using the Point.addRightClickListener() but I can’t get the right [x,y] event position:
CanvasLayer.Point location = canvasLayer.addPoint(GeometryUtils.createPoint(p.getX(), p.getY()));
location.addRightClickListener(rightClickEvent -> {
LMap leafletMap = map.unwrap(LMap.class);
com.haulmont.addon.maps.web.toolkit.ui.leaflet.shared.Point point = new com.haulmont.addon.maps.web.toolkit.ui.leaflet.shared.Point();
ContextMenu contextMenu = new ContextMenu(leafletMap, false);
Resource compassIcon = iconResolver.getIconResource(CubaIcon.COMPASS.source());
contextMenu.addItem("Change point position", compassIcon, selectedItem -> {
location.setEditable(true);
location.addModifiedListener(modifiedEvent -> location.setEditable(false));
});
point.setLon(rightClickEvent.getGeometry().getX());
point.setLat(rightClickEvent.getGeometry().getY());
contextMenu.open((int) rightClickEvent.getGeometry().getX(), (int) rightClickEvent.getGeometry().getY()); // i know, it's incorrect: these are x,y on the map, not in the browser window... so the context menu appears outside the map
});