-
Notifications
You must be signed in to change notification settings - Fork 74
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
removeDrawToolbar clearFeatures doesn't work anymore #148
Comments
Also found that removeDrawToolbar doesn't work at all when a leaflet proxy is used within a shiny app. It used to work just fine. Please find below a simple example.
|
I was using the clearFeatures = TRUE functionality to allow the users to geofence points on the map one drawn shape at a time. |
Just to say the I was only using clearFeatures = TRUE as a workaround. The underlying need to remove features via the code is already covered in #96 |
I was having issues with removeDrawToolbar on a leaflet proxy today. I was getting "...t.drawToolbar.removeFrom is not a function" JS error in my browser's console. I have been able to get it to work by replacing the "removeFrom" methods with just "remove" in inst/htmlwidgets/build/lfx-draw/lfx-draw-bindings.js. However, as I just made this change, I have only verified that it has worked locally. I also haven't gone line-by-line to check if it breaks anything else. (While the initial error was thrown on t.drawToolbar.removeFrom(t), I also did the replacement for 'o.drawToolbar.removeFrom(o)' in the same file as it seems to get triggered when I add a drawToolbar when there is already one) |
See last comment in trafficonese#148
Has anyone found a solution for this? I have a process where the user can utilize the draw toolbar to draw a polygon, and then I take the features from it to hold the data in a reactiveValues dataframe, for the user to go on to do other things with it. Right now the polygon from the draw toolbar does not clear out of the way for the user to interact with the redrawn reactiveValues polygon. |
Was wondering if there was any progress on this issue. Is this package still being maintained? There doesn't seem to be any changes to the repo for a year. It would be great if these changes could be made. |
@ndimhypervol @laldew if you need to get this working sooner rather than later, you can download this package from source, make the change, 'export' the package, then install it locally. That is what I did above to fix the issue. Here's a link to some basics on how to do it in RStudio (you may need to install some other packages to get it to work). Similarly, it looks like @jeroenclaes made a fork called patch-2 where he made the fix (as referenced in the commit above). You could possibly use that as a quick fix. I don't exactly know if the issue I experienced is the same as the issue you are experiencing. If you 'inspect element' on the browser's page after you perform the intended action, are there any errors in the console? |
I am quite sure there is a typo in
should be I wanted to post this before I had the time to try the fix myself. |
@nikkoc Thank you for the fix, and sorry for the late reply. |
I changed this in the source and reinstalled the package. i still can't get the code to remove the drawtoolbar. |
The typo is not the source of that error. One easy workaround would be to use I think the error comes from this line: If it is changed to |
leaflet.extras::removeDrawToolbar(clearFeatures = TRUE)
doesn't seem to clear the features anymore. Anyone else notice this? I see that now there is "clear all features" option on the edit menu for draw. Was there ever a different way implemented to programmatically remove drawn features? Thanks.The text was updated successfully, but these errors were encountered: