Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable finish drawing when existing vertex is clicked #1390

Open
AndrejGajdos opened this issue Aug 23, 2023 · 2 comments
Open

Disable finish drawing when existing vertex is clicked #1390

AndrejGajdos opened this issue Aug 23, 2023 · 2 comments

Comments

@AndrejGajdos
Copy link

When user is drawing a line and existing vertex is clicked, the drawing is finished. How can I disable this behaviour to finish drawing only when "Finish" button is clicked?

@Falke-Design
Copy link
Collaborator

Currently this is not built in, but we will think about adding it.

You can use following code:

      const createMarkerProto = L.PM.Draw.Line.prototype._createMarker;
      const setTooltipTextProto = L.PM.Draw.Line.prototype._setTooltipText;
      L.PM.Draw.Line.include({
        _createMarker: function(latlng){
          const marker = createMarkerProto.call(this, latlng);
          marker.off('click', this._finishShape, this);
          return marker;
        },
        _setTooltipText: function() {
          setTooltipTextProto.call(this);
          const { length } = this._layer.getLatLngs().flat();
          if (length > 1) {
            this._hintMarker.setTooltipContent('Click finish in the Toolbar to create the Line');
          }
        },
      });
      map.pm.Draw.Line = new L.PM.Draw.Line(map);

@AndrejGajdos
Copy link
Author

AndrejGajdos commented Aug 24, 2023

@Falke-Design thank you, this is great improvement, but with this modification it's still possible to finish drawing when user clicks or double clicks the existing vertex. I guess it's because of this code, and perhaps it's not so easy to modify.

geoman-click-existing-vertex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants