Closed matthewtboyle closed 8 months ago
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());
}
};
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:
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.