Closed gmarshall56 closed 3 years ago
Thanks for reporting this issue. This will be already fixed with #956
As workaround you can use this:
var visible = map.pm.controlsVisible();
map.pm.Toolbar.setButtonDisabled('drawMarker', false);
map.pm.Toolbar.isVisible= visible;
To expand on this issue:
Currently when the Draw Polyline button is selected my React js code will put a buffer around the line drawn. This results in two layers placed in the getGeomanLayers array. I would like to replace the Draw Polyline button with a button that when selected will execute code that will take the lat/lngs from a line drawn on the map and create a buffered line ( I think geoman refers to this as a Feature) on the map. I think by doing this then when the user decides to remove the drawing, there will only be one item to remove from the map, versus what we have currently, where the user would have to click twice to remove everything: the first click removes the buffer (the feature), the second click removes the line that was drawn.
To start with this, when the map is present on the page I:
I have put console. info statements before and after step 1 as well as before and after step 2. First, this is my code:
This is what we get: BEFORE addControls:: map.pm.controlsVisible() => returns false <== OK! AFTER addControls:: map.pm.controlsVisible() => returns true <== OK! AFTER copyDrawControl:: map.pm.controlsVisible() => returns false <== NO! Control is visible on the map!
So just for your further information. Perhaps this scenario will be covered as you mentioned unt #956.
BTW: Am I copying to customize the behavior of the Draw Polyline button correctly?
Thank you
Fixed with Release 2.11.3
And how to switch to active the edit button in the toolbar from code?
Hello:
In my code, when it is determined that the Leaftlet map is present, I set map the map draw control on the map but set it to hidden as such:
map.pm.addControls( mapOptions ); map.pm.toggleControls(); //Toggle Draw control to hide
Eventually in my code I toggle the draw control so that it shows.
Also, later in my code I will disable all but one draw control button.
Now I noticed, after this activity when I query map.pm.controlsVisible(), it returns false, while the draw control is showing on the map. See here:
Could this be happening because I have disabled some of the draw control buttons?
Thank you for your time.
UPDATE: Yes, that is what appears to be happening:
map.pm.Toolbar.setButtonDisabled('drawMarker', false);
Is there a way to determine if the draw tool is showing on the map even if there are buttons in the draw tool that have been disabled?
Thank you