r-spatial / mapview

Interactive viewing of spatial data in R
https://r-spatial.github.io/mapview/
GNU General Public License v3.0
518 stars 91 forks source link

Polygons do not display on Windows when using mapviewOptions(platform = "leafgl") #363

Open aakarner opened 3 years ago

aakarner commented 3 years ago

Reproducible example:

library(mapview)
mapviewOptions(platform = "leafgl")
mapview(franconia)

This loads the basemap but I don't see polygons: image

I did some troubleshooting with @tim-salabim on Twitter. Thread here.

If I view the map in a browser, I can see the polygons until I hit F12, then I get an error.

Polygons image

Error DevTools failed to load SourceMap: Could not parse content for http://localhost:17532/glify-browser.js.map: Unexpected token < in JSON at position 0

sessionInfo()


R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] mapview_2.9.8

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6              RColorBrewer_1.1-2      pillar_1.4.6           
 [4] compiler_4.0.3          base64enc_0.1-3         class_7.3-17           
 [7] tools_4.0.3             digest_0.6.25           jsonlite_1.7.1         
[10] satellite_1.0.2         lifecycle_0.2.0         tibble_3.0.3           
[13] lattice_0.20-41         pkgconfig_2.0.3         png_0.1-7              
[16] rlang_0.4.7             rstudioapi_0.11         DBI_1.1.1              
[19] crosstalk_1.1.0.1       yaml_2.2.1              xfun_0.16              
[22] e1071_1.7-4             dplyr_1.0.2             raster_3.3-13          
[25] leaflet.providers_1.9.0 generics_0.0.2          htmlwidgets_1.5.1      
[28] vctrs_0.3.4             webshot_0.5.2           tidyselect_1.1.0       
[31] stats4_4.0.3            classInt_0.4-3          leaflet_2.0.3          
[34] grid_4.0.3              glue_1.4.2              geojsonsf_2.0.0        
[37] sf_0.9-8                R6_2.5.0                jsonify_1.2.1          
[40] leafgl_0.1.2            sp_1.4-2                purrr_0.3.4            
[43] magrittr_2.0.1          scales_1.1.1            codetools_0.2-16       
[46] htmltools_0.5.0         ellipsis_0.3.1          units_0.6-7            
[49] colorspace_1.4-1        tinytex_0.25            KernSmooth_2.23-17     
[52] munsell_0.5.0           leafem_0.1.4            crayon_1.3.4      ```
tim-salabim commented 3 years ago

Which browser are you using as your default browser. I have chrome and so far I am unable to reproduce your issue...

aakarner commented 3 years ago

I'm using Chrome as well: Version 88.0.4324.150 (Official Build) (64-bit).

tim-salabim commented 3 years ago

Ok, so I am using that same Chrome: Version 88.0.4324.150 (Offizieller Build) (64-Bit).

When you say you get the error in the browser when you hit F12, can you please check if the polygons reappear when you move the map slightly (they should).

What you see in the browser console is not an error, it's a warning (so should be ignored ;-) ).

The strange color is some weird result of the shaders used in the upstream repo (I think). You can test by setting alpha.regions = 1 which should keep the colors when opening in the browser:

library(mapview)
mapviewOptions(platform = "leafgl")

mapview(franconia, alpha.regions = 1)

This seems to boil down to an RStudio issue... What's your version? Mine is 1.4.904 and things work fine...

aakarner commented 3 years ago

Thanks. The polygons remain when I move the map slightly. And setting alpha.regions = 1 results in blue polygons in the browser.

I'm using RStudio 1.4.1103 - apparently the current version.

tim-salabim commented 3 years ago

Ok, i'll Upgrade my RStudio tomorrow and see if that enables me to reproduce this.

tim-salabim commented 3 years ago

Sorry for the long silence. I've just updated my RStudio to 1.4.1106. Still cannot reproduce the behaviour. Though I am on linux...