From 1e243ba8cd947a9830f6a73e7d79dbed595b85c1 Mon Sep 17 00:00:00 2001 From: Carson Date: Mon, 24 Feb 2020 09:43:12 -0600 Subject: [PATCH] plot_mapbox() should default to scattermapbox unless z is present, fixes #1707 --- R/plotly_build.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/R/plotly_build.R b/R/plotly_build.R index 87301b4af4..7a50b74c27 100644 --- a/R/plotly_build.R +++ b/R/plotly_build.R @@ -109,10 +109,13 @@ plotly_build.plotly <- function(p, registerFrames = TRUE) { if (is_mapbox(p) || is_geo(p)) { p <- geo2cartesian(p) attrsToEval <- lapply(attrsToEval, function(tr) { - if (!grepl("scatter|choropleth", tr[["type"]] %||% "scatter")) { - stop("Cant add a '", tr[["type"]], "' trace to a map object", call. = FALSE) + type <- tr[["type"]] %||% "scatter" + if (!grepl("scatter|choropleth", type)) { + warning("Can't add a '", type, "' trace to a map object", call. = FALSE) + } + if (is_mapbox(p)) { + tr[["type"]] <- if (!is.null(tr[["z"]])) "choroplethmapbox" else "scattermapbox" } - if (is_mapbox(p)) tr[["type"]] <- tr[["type"]] %||% "scattermapbox" if (is_geo(p)) { tr[["type"]] <- if (!is.null(tr[["z"]])) "choropleth" else "scattergeo" }