leaflet.extras2 icon indicating copy to clipboard operation
leaflet.extras2 copied to clipboard

addEasyprint does only export the top part of a map for "Current Size"

Open myxBeni opened this issue 1 year ago • 2 comments

First of all, many thanks for the great work!

The (wonderful !) easyprint-button only exports the first row of tiles when setting the extent to current size. A4 seems to work.n Tested on Chrome and Safari with the latest version of leaflet.extras2.

pacman::p_load(dplyr, leaflet, leaflet.extras2)

m <- gadmCHE %>% leaflet() %>%
  addPolygons(fillColor = ~colors(NAME_1), fillOpacity = 1,group = "Kantone") %>%
  leaflet.extras2::addEasyprint(options = easyprintOptions(position = "topright",
                                            exportOnly=FALSE, #or true does not change much
                                            filename ="Anmerkung")
              )

htmlwidgets::saveWidget(m,"test_export.html")

Anmerkung-6

myxBeni avatar Aug 19 '22 12:08 myxBeni

If you use the same code within a Shiny-app everything seems to work fine..

library(shiny)  
library(leaflet)
library(leaflet.extras2)

ui <- fluidPage(leafletOutput("map"))

server <- function(input, output, session) {
  output$map <- renderLeaflet({
    leaflet()  %>%
      addTiles(group = "basemap") %>%
      addPolygons(data = gadmCHE,fillOpacity = 1,group = "Kantone") %>%
      leaflet.extras2::addEasyprint(options = easyprintOptions(position = "topright",
                                                               exportOnly=FALSE, #or true does not change much
                                                               filename ="Anmerkung")
      )
    })
}
shinyApp(ui, server)

So not entirely sure where the problem might be.. or if i can fix it.

trafficonese avatar Aug 22 '22 09:08 trafficonese

Indeed, I don't encounter the problem in a Shiny-App opened in a Browser (Firefox and Safari). However, I need to distribute the app to several machines and currently. As we don't run a shiny server, I distributed the HTML...

myxBeni avatar Aug 23 '22 08:08 myxBeni

I looked into this again. The problem is that no height is given to the map-widget, so saveWidget assignes a height of 100%.

If you manually add a height to the widget it works fine.

m$height <- "800px"
htmlwidgets::saveWidget(m,"test_export.html")

trafficonese avatar Apr 20 '23 10:04 trafficonese