mapview provides a few special popup rendering functions. These can be used to generate:
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))
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")
p <- xyplot(copper ~ cadmium, data = meuse@data, col = "grey", pch = 20, cex = 2)
p <- mget(rep("p", length(meuse)))
clr <- rep("grey", length(meuse))
p <- lapply(1:length(p), function(i) {
clr[i] <- "red"
update(p[[i]], col = clr)
})
mapview(meuse,
zcol = "cadmium",
popup = popupGraph(p))
## 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.