trafficonese / leaflet.extras

Extra functionality for leaflet R package.
https://trafficonese.github.io/leaflet.extras/
GNU General Public License v3.0
216 stars 74 forks source link

Fire the "draw_editstart" event at the second time #89

Closed byzheng closed 7 months ago

byzheng commented 7 years ago

See a minimum example for this but: https://github.com/byzheng/leaflet-draw-test

The latest version of leaflet and leaflet.extra packages

Steps to reproduce this bug:

  1. Run the shiny in the respository
  2. Click the edit button to edit any circle (the polygon is clear from the map which is expected)
  3. Save the editing.
  4. Click the dit button again (the polygon is not clear from the map)

In the second edit, there is NO draw_editstart event.

bhaskarvk commented 7 years ago

This could be a limitation/big of the plugin, I will investigate.

bhaskarvk commented 7 years ago

@byzheng Could you help me in debugging this? It should be easy to fire up chrome dev tools, and set up break points in the bindings JS file to figure out what exactly is happening?

bhaskarvk commented 7 years ago

This could be due to some limitation in how Shiny decides to propagate the event back to the server. I see @jcheng5 has added "nonce" : Math.random() in several Shiny.onInputChange calls in the original leaflet pkg JS code. Perhaps I need to add that for draw events too. THoughts @timelyportfolio ?

timelyportfolio commented 7 years ago

Definitely sounds like the repeated-same-events-in-Shiny not getting sent problem https://github.com/daattali/advanced-shiny#message-javascript-r-force. I would generally blame the JS side, but in this case I have not experienced any similar problems with all my work on mapedit.

It might also be that clearGroup does not clear the Leaflet.draw internal mechanism for keeping up with edited features, so Leaflet.draw still thinks the deleted/cleared feature still exists.

trafficonese commented 7 months ago

b7be0d6 should fix this