Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.3
Depends:
R (>= 4.1.0)
Imports:
Expand All @@ -42,3 +41,4 @@ Suggests:
usethis,
leaflet
Config/testthat/edition: 3
Config/roxygen2/version: 8.0.0
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# mapgl (development version)

* Fixed a bug where passing a geometry-only `sf` object (no non-geometry columns) as a layer source caused a serialization error. `geojsonsf::sf_geojson()` simplifies property-less sf objects into a vector of individual geometry strings rather than a FeatureCollection, which `htmlwidgets` cannot serialize. All internal calls now use `simplify = FALSE` to consistently return a FeatureCollection (#212).

# mapgl 0.5.0

* Tooltips and popups now accept `{brace}` templates package-wide. Any layer's `tooltip`/`popup` (and `set_tooltip()`/`set_popup()`) can take a glue-style template such as `"{name}: {population}"`, in addition to the existing column name and `concat()`/`number_format()` expression forms; substituted values are HTML-escaped.
Expand Down
2 changes: 1 addition & 1 deletion R/layers.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ add_layer <- function(
if (sf::st_crs(source) != 4326) {
source <- sf::st_transform(source, crs = 4326)
}
geojson <- geojsonsf::sf_geojson(source)
geojson <- geojsonsf::sf_geojson(source, simplify = FALSE)
source <- list(
type = "geojson",
data = geojson,
Expand Down
2 changes: 1 addition & 1 deletion R/shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ set_source <- function(map, layer_id = NULL, source, layer = NULL) {
source <- geojsonsf::sf_geojson(sf::st_transform(
source,
crs = 4326
))
), simplify = FALSE)
}

if (
Expand Down
2 changes: 1 addition & 1 deletion R/sources.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ add_source <- function(map, id, data, ...) {
if (sf::st_crs(data) != 4326) {
data <- sf::st_transform(data, crs = 4326)
}
geojson <- geojsonsf::sf_geojson(data)
geojson <- geojsonsf::sf_geojson(data, simplify = FALSE)
} else if (is.character(data) && grepl("^http", data)) {
geojson <- data
} else {
Expand Down
30 changes: 15 additions & 15 deletions R/turf.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ turf_buffer <- function(
if (!inherits(data, "sf")) {
stop("data must be an sf object.")
}
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326))
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326), simplify = FALSE)
}

# Validate coordinates
Expand Down Expand Up @@ -176,7 +176,7 @@ turf_union <- function(
if (!inherits(data, "sf")) {
stop("data must be an sf object.")
}
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326))
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326), simplify = FALSE)
}

# Handle proxy objects (Shiny)
Expand Down Expand Up @@ -287,7 +287,7 @@ turf_intersect <- function(
if (!inherits(data, "sf")) {
stop("data must be an sf object.")
}
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326))
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326), simplify = FALSE)
}

# Convert sf data_2 to GeoJSON if provided
Expand All @@ -299,7 +299,7 @@ turf_intersect <- function(
geojson_data_2 <- geojsonsf::sf_geojson(sf::st_transform(
data_2,
crs = 4326
))
), simplify = FALSE)
}

# Handle proxy objects (Shiny)
Expand Down Expand Up @@ -414,7 +414,7 @@ turf_difference <- function(
if (!inherits(data, "sf")) {
stop("data must be an sf object.")
}
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326))
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326), simplify = FALSE)
}

# Convert sf data_2 to GeoJSON if provided
Expand All @@ -426,7 +426,7 @@ turf_difference <- function(
geojson_data_2 <- geojsonsf::sf_geojson(sf::st_transform(
data_2,
crs = 4326
))
), simplify = FALSE)
}

# Handle proxy objects (Shiny)
Expand Down Expand Up @@ -529,7 +529,7 @@ turf_convex_hull <- function(
if (!inherits(data, "sf")) {
stop("data must be an sf object.")
}
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326))
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326), simplify = FALSE)
}

# Validate and process coordinates
Expand Down Expand Up @@ -649,7 +649,7 @@ turf_concave_hull <- function(
if (!inherits(data, "sf")) {
stop("data must be an sf object.")
}
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326))
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326), simplify = FALSE)
}

# Validate and process coordinates
Expand Down Expand Up @@ -769,7 +769,7 @@ turf_voronoi <- function(
if (!inherits(data, "sf")) {
stop("data must be an sf object.")
}
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326))
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326), simplify = FALSE)
}

# Process bbox parameter
Expand Down Expand Up @@ -931,7 +931,7 @@ turf_distance <- function(
if (!inherits(data, "sf")) {
stop("data must be an sf object.")
}
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326))
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326), simplify = FALSE)
}

# Validate coordinates
Expand Down Expand Up @@ -1011,7 +1011,7 @@ turf_area <- function(
if (!inherits(data, "sf")) {
stop("data must be an sf object.")
}
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326))
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326), simplify = FALSE)
}

proxy_class <- if (inherits(proxy, "mapboxgl_proxy")) {
Expand Down Expand Up @@ -1074,7 +1074,7 @@ turf_centroid <- function(
if (!inherits(data, "sf")) {
stop("data must be an sf object.")
}
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326))
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326), simplify = FALSE)
}

# Validate and process coordinates
Expand Down Expand Up @@ -1196,7 +1196,7 @@ turf_center_of_mass <- function(
if (!inherits(data, "sf")) {
stop("data must be an sf object.")
}
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326))
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326), simplify = FALSE)
}

# Validate and process coordinates
Expand Down Expand Up @@ -1332,7 +1332,7 @@ turf_filter <- function(
if (!inherits(data, "sf")) {
stop("data must be an sf object.")
}
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326))
geojson_data <- geojsonsf::sf_geojson(sf::st_transform(data, crs = 4326), simplify = FALSE)
}

# Convert sf filter_data to GeoJSON if provided
Expand All @@ -1344,7 +1344,7 @@ turf_filter <- function(
geojson_filter_data <- geojsonsf::sf_geojson(sf::st_transform(
filter_data,
crs = 4326
))
), simplify = FALSE)
}

# Handle proxy objects (Shiny)
Expand Down
5 changes: 5 additions & 0 deletions man/mapgl-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading