if (FALSE) { # identical(Sys.getenv("R_PRETTYMAPR_HAS_API_KEY"), "true")
# \donttest{
library(prettymapr)
# basic ploting
nsbox <- searchbbox("nova scotia")
osm.plot(nsbox)
osm.plot(nsbox, type="stamenbw")
bmaps.plot(nsbox)
bmaps.plot(nsbox, type="Road")
# use prettymapr to add scalebar and north arrow
prettymap(osm.plot(nsbox))
prettymap(bmaps.plot(nsbox, type="Road"))
# define custom tile types in several ways
# using string formats
ts <- as.tile_source("http://a.basemaps.cartocdn.com/dark_all/${z}/${x}/${y}.png")
osm.plot(nsbox, type=ts)
# using string formats and register_tile_source
register_tile_source(dark = "http://a.basemaps.cartocdn.com/dark_all/${z}/${x}/${y}.png")
osm.plot(nsbox, type="dark")
# set default plot type to something other than 'osm'
set_default_tile_source("stamenbw")
osm.plot(nsbox)
# }
}
Run the code above in your browser using DataLab