Skip to content

Commit 1e243ba

Browse files
committed
plot_mapbox() should default to scattermapbox unless z is present, fixes #1707
1 parent a63b048 commit 1e243ba

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

R/plotly_build.R

+6-3
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,13 @@ plotly_build.plotly <- function(p, registerFrames = TRUE) {
109109
if (is_mapbox(p) || is_geo(p)) {
110110
p <- geo2cartesian(p)
111111
attrsToEval <- lapply(attrsToEval, function(tr) {
112-
if (!grepl("scatter|choropleth", tr[["type"]] %||% "scatter")) {
113-
stop("Cant add a '", tr[["type"]], "' trace to a map object", call. = FALSE)
112+
type <- tr[["type"]] %||% "scatter"
113+
if (!grepl("scatter|choropleth", type)) {
114+
warning("Can't add a '", type, "' trace to a map object", call. = FALSE)
115+
}
116+
if (is_mapbox(p)) {
117+
tr[["type"]] <- if (!is.null(tr[["z"]])) "choroplethmapbox" else "scattermapbox"
114118
}
115-
if (is_mapbox(p)) tr[["type"]] <- tr[["type"]] %||% "scattermapbox"
116119
if (is_geo(p)) {
117120
tr[["type"]] <- if (!is.null(tr[["z"]])) "choropleth" else "scattergeo"
118121
}

0 commit comments

Comments
 (0)