0

I am Creating Map with some areas drawn as polygons. Each area have property AreaNumber. AreaNumber is given in input under map.
Problem is: How to cancel drawing if AreaNumber is not written in input?

Possible solutions make user unable to press create button while input is empty with popup message, or Cancel in map.on(draw: drawstart) if input is empty after giving popup message. How to call cancel buttons function from code?

1
  • Was able to find a way to not draw it, if AreaNumber is empty.(in map.on(draw:created) just check if input is filled or not before adding layer to FeatureGroup. It helps with deleting figure if input is not filled. But i want user to stop drawing it. Will appreciate any solutions.
    – FallenOne
    Commented Jul 27, 2023 at 3:22

1 Answer 1

0

I didnt find a way to call cancel button. But was able to find a way to cancell drawing by removing draw control then adding it again, whenever i need it.

Example:

map.on("draw:drawstart", function (e) {
    var err = PsNumber.value;

    if (err == '') {
        alert("Alert popup");
        map.removeControl(drawControl);
        map.addControl(drawControl);
    }
});

Code will show error and cancel drawing automatically.

Not the answer you're looking for? Browse other questions tagged or ask your own question.