@@ -75,15 +75,12 @@ plotly_build.plotly <- function(p) {
7575
7676 # trace type checking and renaming for plot objects
7777 if (is_mapbox(p ) || is_geo(p )) {
78+ p <- geo2cartesian(p )
7879 p $ x $ attrs <- lapply(p $ x $ attrs , function (tr ) {
79- tr [[" x" ]] <- tr [[" x" ]] %|| % tr [[" lat" ]]
80- tr [[" y" ]] <- tr [[" y" ]] %|| % tr [[" lon" ]]
8180 if (! grepl(" scatter|choropleth" , tr [[" type" ]] %|| % " scatter" )) {
8281 stop(" Cant add a '" , tr [[" type" ]], " ' trace to a map object" , call. = FALSE )
8382 }
84- if (is_mapbox(p )) {
85- tr [[" type" ]] <- " scattermapbox"
86- }
83+ if (is_mapbox(p )) tr [[" type" ]] <- " scattermapbox"
8784 if (is_geo(p )) {
8885 tr [[" type" ]] <- if (! is.null(tr [[" z" ]])) " choropleth" else " scattergeo"
8986 }
@@ -99,6 +96,7 @@ plotly_build.plotly <- function(p) {
9996 rapply(x , eval_attr , data = dat , how = " list" ),
10097 class = oldClass(x )
10198 )
99+
102100 # if appropriate, tack on a group index
103101 grps <- tryCatch(
104102 as.character(dplyr :: groups(dat )),
@@ -478,6 +476,7 @@ map_color <- function(traces, title = "", na.color = "transparent") {
478476 if (traces [[i ]][[" type" ]] == " contour" ) {
479477 traces [[i ]]$ colorscale [, 2 ] <- strip_alpha(traces [[i ]]$ colorscale [, 2 ])
480478 }
479+ traces [[i ]] <- structure(traces [[i ]], class = c(" plotly_colorbar" , " zcolor" ))
481480 next
482481 }
483482 colorObj $ color <- color [[i ]]
0 commit comments