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