• Stars
    star
    111
  • Rank 303,236 (Top 7 %)
  • Language
    R
  • License
    Other
  • Created about 5 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Include Tables, Images and Graphs in Leaflet Popups

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

Or the development version from GitHub:

# install.packages("devtools")
devtools::install_github("r-spatial/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.

More Repositories

1

sf

Simple Features for R
R
1,265
star
2

rgee

Google Earth Engine for R
R
627
star
3

stars

Spatiotemporal Arrays, Raster and Vector Data Cubes
R
531
star
4

mapview

Interactive viewing of spatial data in R
JavaScript
503
star
5

leafgl

R package for fast web gl rendering for leaflet
R
257
star
6

mapedit

Interactive editing of spatial data in R
R
216
star
7

qgisprocess

R package to use QGIS processing algorithms
R
193
star
8

RQGIS

RQGIS - integrating R with QGIS
R
189
star
9

gstat

Spatial and spatio-temporal geostatistical modelling, prediction and simulation
C
188
star
10

dtwSat

Time-Weighted Dynamic Time Warping for satellite image time series analysis
R
125
star
11

spdep

Spatial Dependence: Weighting Schemes and Statistics
R
111
star
12

leafem

leaflet extensions for mapview
JavaScript
104
star
13

RQGIS3

R
69
star
14

s2

Spherical Geometry Operators Using the S2 Geometry Library
C++
69
star
15

r-spatial.org

r-spatial.org blog sources
HTML
58
star
16

lwgeom

bindings to the liblwgeom library
C
57
star
17

discuss

a discussion repository: raise issues, or contribute!
54
star
18

sfdbi

DBI interface to sf
R
53
star
19

sftime

time extension to sf objects
R
49
star
20

spatialreg

spatialreg: spatial models estimation and testing
R
41
star
21

rspatial_spark

This is the repo that sparked https://github.com/r-spatial
HTML
36
star
22

cesium

Cesium wrapper to R
R
33
star
23

leafsync

Small Multiples for Leaflet Webmaps
JavaScript
32
star
24

global

R-global: analysing spatial data globally
HTML
31
star
25

classInt

Choose Univariate Class Intervals
R
29
star
26

RPyGeo

Update of RPyGeo package - currently WIP
R
27
star
27

link2GI

Simplify the linking of GIS/RS and CLI tools
R
25
star
28

slideview

Compare Rasters Side by Side with a Slider
R
25
star
29

evolution

Preparing CRAN for the retirement of rgdal, rgeos and maptools
TeX
24
star
30

cubeview

Interactively Explore 3D Raster Data Cubes
JavaScript
24
star
31

leafpm

Leaflet.pm for R Leaflet
R
22
star
32

RSAGA

R
19
star
33

plainview

View Raster Images Interactively on a Plain HTML Canvas
R
13
star
34

rgeopackage

R package with helper tools in creating or handling GeoPackage files
R
9
star
35

task_views

Local copy for editing CRAN Task Views
R
9
star
36

r-spatial.github.io

r-spatial.github.io website
HTML
5
star