From 9d4afd0f72b6f8f40034d1afc2b1b7dbbf845864 Mon Sep 17 00:00:00 2001 From: tim-salabim Date: Sat, 28 Apr 2018 10:48:40 +0200 Subject: [PATCH] hotfix canvas --- R/sf.R | 48 ++++++++++-------------------------------------- 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/R/sf.R b/R/sf.R index 5b1eeb038..99f2be9a2 100644 --- a/R/sf.R +++ b/R/sf.R @@ -151,7 +151,7 @@ leaflet_sfc <- function(x, if (!is.null(names(x))) { names(x) = NULL } - # x = x[!is.na(sf::st_dimension(x))] + if (inherits(x, "XY")) x = sf::st_sfc(x) if (!native.crs) x <- checkAdjustProjection(x) @@ -169,44 +169,18 @@ leaflet_sfc <- function(x, m <- initMap(map, map.types, sf::st_crs(x), native.crs, canvas = canvas) - if (!is.null(pane)) { - if (pane == "auto" & !canvas) { - pane = paneName(x) - zindex = zIndex(x) - m = addMapPane(m, pane, zindex) + if (!canvas) { + if (!is.null(pane)) { + if (pane == "auto") { + pane = paneName(x) + zindex = zIndex(x) + m = addMapPane(m, pane, zindex) + } } + } else { + pane = NULL } - # if (featureComplexity(x) > maxpoints) { - # cat(large_warn) - # if(interactive()) { - # installChoice <- menu(c("yes", "no")) - # if(installChoice == 1){ - # vwr = options("viewer") - # options(viewer = NULL) - # } - # } - # } - - # if (featureComplexity(x) > maxpoints) { - # if (getGeometryType(x) == "ln") clrs <- color else clrs <- col.regions - # warning(large_warn) - # m <- addLargeFeatures(m, - # data = x, - # radius = cex, - # weight = lwd, - # opacity = alpha, - # fillOpacity = alpha.regions, - # color = clrs, - # popup = popup, - # label = label, - # group = layer.name, - # maxpoints = maxpoints, - # attributes = attributes, - # ...) - # - # } else { - m <- addFeatures(m, data = x, pane = pane, @@ -222,8 +196,6 @@ leaflet_sfc <- function(x, highlightOptions = highlight, ...) - # } - if (!is.null(map)) m = updateOverlayGroups(m, layer.name) sclbrpos = getCallEntryFromMap(m, "addScaleBar") if (length(sclbrpos) > 0 | native.crs) scalebar = FALSE else scalebar = TRUE