[Map] Cancel drawing mode in CanvasLayer

Hi,
is there a way to cancel drawing mode without having user to click on the map?
Let me explain.
If I invoke geoMap.getCanvas().drawPoint() the map activates the point drawing mode and a crosshair appears to let user choose the point: correct.
But if the user changes his mind because he doesn’t know the exact location of a place and he decides to user another tool (for instance a searchbar to find the correct place), I can’t find any method in CanvasLayer to cancel editing mode… so the next time user clicks on map, it will appear an unwanted point.
Looking for a solution, I’ve found in class com.haulmont.addon.maps.web.gui.components.LeafletCanvasLayer the method deactivate() which should do the job but I can’t use it.
How should I do this?
Thanks in advance.
Regards,
Paolo

2 Likes

Hi, Paolo!

That’s a good point. It would be useful to have a method like cancelDrawing() in the CanvasLayer. We will add it in the next release.

As for now, you can achieve this by unselecting the canvas and then selecting it back:

    public void cancelDrawing() {
        map.selectLayer(null);
        map.selectLayer(map.getCanvas());
    }

UPDATE:
In the 1.3 version cancelDrawing() method has been added to the CanvasLayer.

Regards,
Gleb

It works perfectly!
Thanks Gleb.
Regards,
Paolo