Skip to content

Commit 44df7d1

Browse files
authored
fix addPolygon with sf names (#613)
* sanitise names * added news item for fixing 595 * roxygen version updated * roxygen caused update to .Rd * move sanitization of sf st_geometries into a helper method * document expr directly
1 parent e780e4b commit 44df7d1

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ Suggests:
6363
RJSONIO,
6464
purrr,
6565
testthat
66-
RoxygenNote: 6.1.0
66+
RoxygenNote: 6.1.1
6767
Encoding: UTF-8
6868
LazyData: true

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ leaflet 2.0.3
44
BUG FIXES and IMPROVEMENTS
55
* Fixed [rstudio/crosstalk#58](https://github.com/rstudio/crosstalk/issues/58), which caused Leaflet maps that used Crosstalk shared data in Shiny apps, to be redrawn at incorrect times.
66
* Upgrade leaflet-provider to 1.4.0, enable more map variants such as CartoDB.Voyager (#567)
7+
* `sf` objects with `names` attributes in the `st_geometry` now visualise correctly (#595)
78

89

910

R/normalize-sf.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ metaData.sf <- function(obj) {
66
}
77

88
# pointsData --------------------------------------------------------------
9+
sanitize_sf <- function(obj) {
10+
sanitized_sf <- sf::st_geometry(obj)
11+
attr(sanitized_sf, "names") <- NULL
12+
sanitized_sf
13+
}
14+
915

1016
#' @export
1117
pointData.sf <- function(obj) {
12-
pointData(sf::st_geometry(obj))
18+
pointData(sanitize_sf(obj))
1319
}
1420

1521
#' @export
@@ -67,7 +73,7 @@ pointData.sfc_GEOMETRY <- function(obj) {
6773

6874
#' @export
6975
polygonData.sf <- function(obj) {
70-
polygonData(sf::st_geometry(obj))
76+
polygonData(sanitize_sf(obj))
7177
}
7278

7379
#' @export

R/shiny.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ leafletOutput <- function(outputId, width = "100%", height = 400) {
2222
htmlwidgets::shinyWidgetOutput(outputId, "leaflet", width, height, "leaflet")
2323
}
2424

25+
# use expr description from htmlwidgets to avoid bad inherit params code
26+
#' @param expr An expression that generates an HTML widget (or a
27+
#' \href{https://rstudio.github.io/promises/}{promise} of an HTML widget).
2528
#' @rdname map-shiny
2629
#' @export
2730
renderLeaflet <- function(expr, env = parent.frame(), quoted = FALSE) {

man/map-shiny.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)