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

Error when drawing text box after toolbar button is enabled and moving directly from mode other than draw #1422

Closed
matthewtboyle opened this issue Nov 22, 2023 · 1 comment · Fixed by #1424
Labels
fixed Issues that are fixed in develop or in a PR

Comments

@matthewtboyle
Copy link

matthewtboyle commented Nov 22, 2023

Here is the JSFiddle https://jsfiddle.net/matthewtboyle/r1cdufga/3/

This fiddle is set up to disable or enable the drawText toolbar button on zoom end. When you open the fiddle:

  1. click toolbar button to enter edit mode
  2. zoom out so that the drawText button is disabled.
  3. zoom in until drawText button is enabled
  4. click the drawText button.

I don't see the details of the error in the JSFiddle, but in my environment it looks like this:

global-error-handler.ts:22 handleError TypeError: Cannot read properties of undefined (reading 'remove') at NewClass.disable (leaflet-geoman.min.js:1:149230) at NewClass.toggle (leaflet-geoman.min.js:1:149529) at Object.afterClick (leaflet-geoman.min.js:1:80589) at NewClass._triggerClick (leaflet-geoman.min.js:1:69847) at NewClass.triggerClickOnToggledButtons (leaflet-geoman.min.js:1:76640) at NewClass.toggleButton (leaflet-geoman.min.js:1:76838) at NewClass.disableGlobalEditMode (leaflet-geoman.min.js:1:39953) at NewClass.toggleGlobalEditMode (leaflet-geoman.min.js:1:40328) at Object.afterClick (leaflet-geoman.min.js:1:79022) at NewClass._triggerClick (leaflet-geoman.min.js:1:69847)

It looks like it is trying to remove a hintMarker that does not exist.

I do know that when moving to draw mode from another active mode Geoman is disabling all other modes. This remove happens in L.PM.Draw.Text.disable(). Maybe enabling the drawText button is causing Geoman to think we need to run L.PM.Draw.Text.disable() when LPM.Draw.Text.toggle() is run?

Any help is appreciated.

@Falke-Design
Copy link
Collaborator

Thank you for creating this issue. It will be fixed in the next version. #1424

Until the release you can use following workaround:

map.pm.Toolbar.buttons.drawText._button.onClick = function() {
  if (map.pm.Draw.Text._enabled && !map.pm.Draw.Text._hintMarker) {
    map.pm.Draw.Text._hintMarker = L.marker(map.getCenter());
  }
};

https://jsfiddle.net/pjshyoru/

@Falke-Design Falke-Design added the fixed Issues that are fixed in develop or in a PR label Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Issues that are fixed in develop or in a PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants