JamesLMilner / terra-draw

A library for drawing on maps that supports Mapbox, MapLibre, Google Maps, OpenLayers and Leaflet out the box
https://terradraw.io
MIT License
485 stars 57 forks source link

Graphics editing status, no Finish event triggered. #231

Closed Thunder7991 closed 5 months ago

Thunder7991 commented 7 months ago

Describe the bug Graphic editing status, mouse over other DOM elements, click on the element, the graphic does not trigger the Finish event.

Editing within the map area, everything is normal.

Thunder7991 commented 7 months ago

Hey, @JamesLMilner ,If you have time, could you please take a look at this issue。

JamesLMilner commented 6 months ago

Hey @Thunder7991 - I will take a look when I get some time. I am away this week and don't always have as much time as I'd like to work on Terra Draw unfortunately.

JamesLMilner commented 5 months ago

@Thunder7991 if I am understanding correctly, you are saying clicking outside of the map DOM element when trying to close a polygon (or maybe other mode) is triggering onFinish or closing the polygon. This is expected behaviour as Terra Draw does not attach event listeners to other DOM nodes within your page. and only has listeners on the map container. As such I will close this issue as it sounds like this is working as intended.

If I have misunderstood your issue, please feel free to raise a new issue with clear reproduction steps and explanation of what you are expecting to happen. Thanks!

Thunder7991 commented 5 months ago

@Thunder7991 if I am understanding correctly, you are saying clicking outside of the map DOM element when trying to close a polygon (or maybe other mode) is triggering onFinish or closing the polygon. This is expected behaviour as Terra Draw does not attach event listeners to other DOM nodes within your page. and only has listeners on the map container. As such I will close this issue as it sounds like this is working as intended.

If I have misunderstood your issue, please feel free to raise a new issue with clear reproduction steps and explanation of what you are expecting to happen. Thanks!

You understand that it is correct. During the drawing process, if you click the DOM element, the graphic does not trigger the Finish incident. In my FOCK version, I tried to make a judgment in related events and solved this problem.

onClick(event: TerraDrawMouseEvent) {
        if (this.selected.length) {
            this.setCursor(this.cursors.dragEnd);
            // If we have finished dragging a coordinate or a feature
            // lets fire an onFinish event which can be listened to
            if (this.dragCoordinate.isDragging()) {
                this.onFinish(this.selected[0]);
            } else if (this.dragFeature.isDragging()) {
                this.onFinish(this.selected[0]);
            } else if (this.dragCoordinateResizeFeature.isDragging()) {
                this.onFinish(this.selected[0]);
            }

            this.dragCoordinate.stopDragging();
            this.dragFeature.stopDragging();
            this.dragCoordinateResizeFeature.stopDragging();
            this.rotateFeature.reset();
            this.scaleFeature.reset();
            // this.deselect();
        }
      ...