mapview provides a few special popup rendering functions. These can be used to generate:
- attribute table popups
- graph popups (i.e. plots in popups)
- static (ggplot2, lattice, base)
- interactive (htmlwidgets)
- image popups
Attribute table popups
popupTable
is the standard popup function used in
mapview. It provides a static table rendering of all attributes of the
individual features.
library(mapview)
library(leaflet)
library(leafpop)
mapview(breweries, popup = popupTable(breweries,
zcol = c("brewery",
"village",
"founded")))
This can also be used with leaflet maps
leaflet() %>%
addTiles() %>%
addCircleMarkers(data = breweries,
popup = popupTable(breweries))
Graph popups
popupGraph
allows us to include static or interactive
(htmlwidgets) plots in popups. In the following example we will show a
scatterplot of copper ~ cadmium for each individual feature of the
famous meuse data set
library(lattice)
library(sp)
data(meuse)
coordinates(meuse) <- ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")
## Warning in CPL_crs_from_input(x): GDAL Message 1: +init=epsg:XXXX syntax is
## deprecated. It might return a CRS with a non-EPSG compliant axis order.