rstudio / leaflet

R Interface to Leaflet Maps
http://rstudio.github.io/leaflet/
Other
807 stars 508 forks source link

Why does EditLayers keep crashing my RStudio? #642

Open zachasman opened 5 years ago

zachasman commented 5 years ago

I'm trying to edit the layer in this map, but it keeps crashing my computer when I select it. All the other toolbar functionalities seem to work fine. What's happening

library(sf)
library(leaflet)
library(leaflet.extras)
library(sp)
library(rmapshaper)
library(dplyr)
library(tigris)
library(rbgm)

nevada <- voting_districts("nevada")
nevada <- rmapshaper::ms_simplify(nevada)

leaflet() %>% addTiles %>%
  addPolygons(data = nevada, group = 'model') %>%
  addDrawToolbar(targetGroup = 'model',
                 editOptions = editToolbarOptions(
                   selectedPathOptions = selectedPathOptions())) %>%
  addLayersControl(overlayGroups = c('model'), options =
                     layersControlOptions(collapsed=FALSE)) %>%
  addStyleEditor()
jcheng5 commented 5 years ago

What operating system? What version of RStudio? Does the same thing happen if you pop the map out into an external browser before editing?

zachasman commented 5 years ago

What operating system? What version of RStudio? Does the same thing happen if you pop the map out into an external browser before editing?

@jcheng5

MacOs Mojave Version 1.3.443

Could you please try running it? I'm curious to know if this is just an issue with my computer, my RStudio or if there's something left out in the code causing it.

jcheng5 commented 5 years ago

Wow, it's pretty bad--there's JS code spinning out of control. I repro'd this on Windows in RStudio, Firefox, and Chrome; hundreds of this deprecation warning in the JS console:

Deprecated use of _flat, please use L.LineUtil.isFlat instead.

This repros even without the addLayersControl or addStyleEditor calls; all that's necessary is to add the Draw toolbar, and click the little Edit icon, that immediately puts you into the bad state.

zachasman commented 5 years ago

@jcheng5 FWIW, maybe I'm doing it incorrectly? I'm trying to follow the third example from this page. That seems to run so smoothly.

library(rbgm)
set.seed(2)
## pick one of the available model files
fs <- sample(bgmfiles::bgmfiles(), 1)

## read the model, and convert to Spatial (box for polygons, face for boundary lines)
model <- boxSpatial(bgmfile(fs))
## most of the BGM models will be in a local map projection
model <- spTransform(model, "+init=epsg:4326")
leaflet() %>% addTiles() %>%
  addPolygons(data = model, group = 'model') %>%
  addDrawToolbar(targetGroup = 'model',
    editOptions = editToolbarOptions(
      selectedPathOptions = selectedPathOptions())) %>%
  addLayersControl(overlayGroups = c('model'), options =
                     layersControlOptions(collapsed=FALSE)) %>%
  addStyleEditor()
zachasman-bernie commented 5 years ago

Anything?

zachasman commented 4 years ago

@jcheng5 Has there been any sort of update on this issue?

zachasman commented 4 years ago

@alandipert Has there been any sort of update on this issue?

zachasman commented 4 years ago

@alandipert @jcheng5 I will take that as a no