@@ -253,6 +253,9 @@ plot_mapbox <- function(data = data.frame(), ...) {
253253# '
254254# ' @param data A data frame (optional).
255255# ' @param ... arguments passed along to [plot_ly()].
256+ # ' @param offline whether or not to include geo assets so that the map
257+ # ' can be viewed with or without an internet connection. The plotlyGeoAssets
258+ # ' package is required for this functionality.
256259# ' @export
257260# ' @author Carson Sievert
258261# ' @seealso [plot_ly()], [plot_mapbox()], [ggplotly()]
@@ -263,8 +266,22 @@ plot_mapbox <- function(data = data.frame(), ...) {
263266# ' plot_geo(x = ~long, y = ~lat) %>%
264267# ' add_markers(size = I(1))
265268# '
266- plot_geo <- function (data = data.frame (), ... ) {
269+ plot_geo <- function (data = data.frame (), ... , offline = FALSE ) {
267270 p <- plot_ly(data , ... )
271+
272+ if (isTRUE(offline )) {
273+ if (system.file(package = " plotlyGeoAssets" ) == " " ) {
274+ stop(
275+ " The plotlyGeoAssets package is required to make 'offline' maps. " ,
276+ " Please install and try again." ,
277+ call. = FALSE
278+ )
279+ }
280+ p $ dependencies <- c(
281+ list (plotlyGeoAssets :: geo_assets()),
282+ p $ dependencies
283+ )
284+ }
268285 # not only do we use this for is_geo(), but also setting the layout attr
269286 # https://plot.ly/r/reference/#layout-geo
270287 p $ x $ layout $ mapType <- " geo"
0 commit comments