How to use Leaflet zoomControl = FALSE???

788 views
Skip to first unread message

Rafael Batista

unread,
Mar 29, 2017, 9:43:04 AM3/29/17
to Shiny - Web Framework for R
Hi all.

I have the following piece of code into a shiny server.R:

  output$mast_map <- renderLeaflet({
    leaflet() %>%
    setView(lng = input$lon, lat = input$lat, zoom = 13) %>%
    addTiles() %>%  # Add default OpenStreetMap map tiles
    addMarkers(lng=input$lon, lat=input$lat, popup="Mast location")
    })

It works. But I want to remove those 2 buttons for control the zoom of the plot.

I tried a few things and I didnt figured out how to use this option zoomControl = FALSE

Where should I put it?

I also want to remove those small texts on the bottom of the plot. I believed that I can do this with attributionControl option. But likewise I dont know how to do it. Can someone please give me a hand?
Cheers.

Rafael Batista

unread,
Mar 29, 2017, 1:46:56 PM3/29/17
to Shiny - Web Framework for R
Forget it...

I realized that I was using an older version of leaflet. After update it works.
But now other bug is happening... this one:

Leaflet map is rendering perfectly on Rstudio but its not passing to the HTML (I ended up with a gray map). 
¬¬

Rafael Batista

unread,
Mar 30, 2017, 10:37:23 AM3/30/17
to Shiny - Web Framework for R
Does anybody now how to remove zoomcontrol on leaflet 1.0.1?

When I tried this code
leaflet(options = leafletOptions(zoomControl = FALSE))
on 1.1.0 it works.

However for 1.0.1 it didnt.

Cheers.

Joe Cheng

unread,
Mar 30, 2017, 12:42:08 PM3/30/17
to Rafael Batista, Shiny - Web Framework for R
Is there a reason you can't upgrade?

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/0951abd4-bb25-437d-ac94-02a064ee363c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rafael Batista

unread,
Mar 30, 2017, 1:04:28 PM3/30/17
to Shiny - Web Framework for R, rafael...@gmail.com
Hi Joe.

As a background information:
I did a shiny code to automatize a report creation here at work. The problem is that the script is being running individually by every user (50 users more or less) (hosting the code in a server was not an option to me due to some security restrictions).

This "old" and first version of the code is working but I wanted to remove those zoom buttons.

Thats why I tried to change some parts of the code on MY computer... before send to everyone. The problem is that I updated everything related to R on my computer so now even pandoc is giving me headache. I got gray maps and now not even the reports are being printed. So my code is messed up but the first version of it is still functional and I want to leave like that. Thats why I cannot update leaflet now.

Here is my sessionInfo:
sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252    LC_MONETARY=Portuguese_Brazil.1252
[4] LC_NUMERIC=C                       LC_TIME=Portuguese_Brazil.1252    

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

other attached packages:
[1] rmarkdown_1.4      RColorBrewer_1.1-2 gplots_3.0.1       openair_2.0-0      maps_3.1.1         zoo_1.7-14         shinyBS_0.61      
[8] leaflet_1.1.0      shiny_1.0.0       

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.10        plyr_1.8.4          bitops_1.0-6        tools_3.3.1         digest_0.6.12       evaluate_0.10      
 [7] jsonlite_1.3        lubridate_1.6.0     tibble_1.2          nlme_3.1-128        lattice_0.20-33     mgcv_1.8-12        
[13] Matrix_1.2-6        DBI_0.6             mapproj_1.2-4       crosstalk_1.0.0     yaml_2.1.14         hexbin_1.27.1      
[19] knitr_1.15.1        dplyr_0.5.0         stringr_1.2.0       cluster_2.0.4       caTools_1.17.1      htmlwidgets_0.8    
[25] gtools_3.5.0        rprojroot_1.2       grid_3.3.1          R6_2.2.0            gdata_2.17.0        latticeExtra_0.6-28
[31] reshape2_1.4.2      magrittr_1.5        backports_1.0.5     htmltools_0.3.5     MASS_7.3-45         assertthat_0.1     
[37] mime_0.5            xtable_1.8-2        httpuv_1.3.3        KernSmooth_2.23-15  stringi_1.1.3       lazyeval_0.2.0


This is the error when I tried to generate the report (on my computer)

"C:\Program Files\RStudio\bin\pandoc/pandoc" +RTS -K512m -RTS 24_12_report.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output 24_12_report.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\rafael.batista\Documents\R\win-library\3.3\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\RAFAEL~1.BAT\AppData\Local\Temp\Rtmp6Nox4n\rmarkdown-str3acc1a826b60.html" --mathjax --variable "mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --id-prefix section- 
Warning: running command '"C:\Program Files\RStudio\bin\pandoc/pandoc" +RTS -K512m -RTS 24_12_report.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output 24_12_report.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\rafael.batista\Documents\R\win-library\3.3\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\RAFAEL~1.BAT\AppData\Local\Temp\Rtmp6Nox4n\rmarkdown-str3acc1a826b60.html" --mathjax --variable "mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --id-prefix section-' had status 127
Warning: Error in : pandoc document conversion failed with error 127
Stack trace (innermost first):
    68: pandoc_convert
    67: convert
    66: rmarkdown::render
    65: observeEventHandler [C:\Users\rafael.batista\Documents\shiny_locally\dist\shiny/server.R#434]
     1: shiny::runApp
ERROR: [on_request_read] connection reset by peer


Joe Cheng

unread,
Mar 30, 2017, 1:17:21 PM3/30/17
to Rafael Batista, Shiny - Web Framework for R
OK, that's fair.

Can you try passing options=list(zoomControl=FALSE) to the leaflet() function?

Rafael Batista

unread,
Mar 30, 2017, 1:23:48 PM3/30/17
to Shiny - Web Framework for R, rafael...@gmail.com
Just tried.

For the old version I got an error:

Error: unused argument (options = list(zoomControl = FALSE))

In the updated leaflet works. Maybe is the case that this options were not available at version 1.0.1???

Joe Cheng

unread,
Mar 30, 2017, 4:50:39 PM3/30/17
to Rafael Batista, Shiny - Web Framework for R
Looks like that's the case.

Eh, just add this to your UI and call it a day :)

tags$head(tags$style(".leaflet-control-zoom { display: none; }"))

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages