leafpop
creates HTML strings to embed tables, images or graphs in
popups of interactive maps created with packages ‘leaflet’ or ‘mapview’.
Handles local paths to images on the file system or remote urls. Handles
graphs created with ‘base’ graphics, ‘lattice’ or ‘ggplot2’ as well as
interactive plots created with ‘htmlwidgets’.
You can install the released version of leafpop
from
CRAN with:
install.packages("leafpop")
Or the development version from GitHub:
# install.packages("devtools")
devtools::install_github("r-spatial/leafpop")
library(leaflet)
leaflet() %>%
addTiles() %>%
addCircleMarkers(data = breweries91,
popup = popupTable(breweries91))
library(sf)
library(leaflet)
pnt = st_as_sf(data.frame(x = 174.764474, y = -36.877245),
coords = c("x", "y"),
crs = 4326)
img = "http://bit.ly/1TVwRiR"
leaflet() %>%
addTiles() %>%
addCircleMarkers(data = pnt, group = "pnt") %>%
addPopupImages(img, group = "pnt")
Alternatively you can bind the images directly in in the add*
call,
however, this will not include the images when the map is saved using
mapshot
or saveWidget
. This options is basically available for
backward compatibility only.
leaflet() %>%
addTiles() %>%
addCircleMarkers(data = pnt, popup = popupImage(img, src = "remote"))
library(sf)
library(leaflet)
library(lattice)
pnt = st_as_sf(data.frame(x = 174.764474, y = -36.877245),
coords = c("x", "y"),
crs = 4326)
p2 = levelplot(t(volcano), col.regions = terrain.colors(100))
leaflet() %>%
addTiles() %>%
addCircleMarkers(data = pnt, group = "pnt") %>%
addPopupGraphs(list(p2), group = "pnt", width = 300, height = 400)
Alternatively you can bind the graphs directly in in the add*
call,
however, this will not include the graphs when the map is saved using
mapshot
or saveWidget
. This options is basically available for
backward compatibility only.
leaflet() %>%
addTiles() %>%
addCircleMarkers(data = pnt, popup = popupGraph(p2, width = 300, height = 400))
See the mapview documentation for further examples.
Please note that the ‘leafpop’ project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.