Skip to content
Include Tables, Images and Graphs in Leaflet Popups
R JavaScript
Branch: master
Clone or download
tim-salabim merge vectorized and get ird of cpp
Merge branch 'vectorized'

# Conflicts:
#	DESCRIPTION
Latest commit a949470 Sep 7, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R merge vectorized and get ird of cpp Sep 7, 2019
inst merge vectorized and get ird of cpp Sep 7, 2019
man
.Rbuildignore
.gitignore
.travis.yml include travis yaml Apr 5, 2019
CODE_OF_CONDUCT.md add readme and code of conduct Apr 5, 2019
DESCRIPTION merge vectorized and get ird of cpp Sep 7, 2019
LICENSE cph Tim Appelhans Apr 27, 2019
NAMESPACE merge vectorized and get ird of cpp Sep 7, 2019
NEWS update news and bump version Jun 20, 2019
NEWS.md update news and bump version Jun 20, 2019
README.Rmd inform users of dev version, in case some examples don't work Jun 22, 2019
README.md new functions addPopupImages & addpopupGraphs to proprtly register im… Jun 20, 2019
leafpop.Rproj initial commit Apr 5, 2019

README.md

Include Tables, Images and Graphs in Leaflet Popups

cran checks Travis build status monthly total CRAN status

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’.

Installation

You can install the released version of leafpop from CRAN with:

install.packages("leafpop")

Examples

popupTable

library(leaflet)

leaflet() %>%
  addTiles() %>%
  addCircleMarkers(data = breweries91,
                   popup = popupTable(breweries91))

addPopupImages & popupImage

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"))

popupGraph

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))

Further examples

See the mapview documentation for further examples.

Code of Conduct

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.

You can’t perform that action at this time.