@@ -253,6 +253,9 @@ plot_mapbox <- function(data = data.frame(), ...) {
253
253
# '
254
254
# ' @param data A data frame (optional).
255
255
# ' @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.
256
259
# ' @export
257
260
# ' @author Carson Sievert
258
261
# ' @seealso [plot_ly()], [plot_mapbox()], [ggplotly()]
@@ -263,8 +266,22 @@ plot_mapbox <- function(data = data.frame(), ...) {
263
266
# ' plot_geo(x = ~long, y = ~lat) %>%
264
267
# ' add_markers(size = I(1))
265
268
# '
266
- plot_geo <- function (data = data.frame (), ... ) {
269
+ plot_geo <- function (data = data.frame (), ... , offline = FALSE ) {
267
270
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
+ }
268
285
# not only do we use this for is_geo(), but also setting the layout attr
269
286
# https://plot.ly/r/reference/#layout-geo
270
287
p $ x $ layout $ mapType <- " geo"
0 commit comments