# NOT RUN {
## include columns 1 and 2 only
mapview(franconia, popup = popupTable(franconia, zcol = 1:2))
mapview(breweries, zcol = "founded", legend = TRUE,
popup = popupTable(breweries, zcol = c("founded", "village")))
leaflet() %>% addCircleMarkers(data = breweries)
leaflet() %>% addCircleMarkers(data = breweries,
popup = popupTable(breweries))
# }
# NOT RUN {
# }
# NOT RUN {
## remote images -----
### one image
library(sf)
pnt = st_as_sf(data.frame(x = 174.764474, y = -36.877245),
coords = c("x", "y"),
crs = 4326)
img = "http://bit.ly/1TVwRiR"
mapview(pnt, popup = popupImage(img, src = "remote"))
### multiple file (types)
library(sp)
images = c(img,
"https://upload.wikimedia.org/wikipedia/commons/9/91/Octicons-mark-github.svg",
"https://www.r-project.org/logo/Rlogo.png",
"https://upload.wikimedia.org/wikipedia/commons/d/d6/MeanMonthlyP.gif")
pt4 = data.frame(x = jitter(rep(174.764474, 4), factor = 0.01),
y = jitter(rep(-36.877245, 4), factor = 0.01))
coordinates(pt4) = ~ x + y
proj4string(pt4) = "+init=epsg:4326"
mapview(pt4, popup = popupImage(images)) # NOTE the gif animation
## local images -----
pnt = st_as_sf(data.frame(x = 174.764474, y = -36.877245),
coords = c("x", "y"), crs = 4326)
img = system.file("img","Rlogo.png",package="png")
mapview(pnt, popup = popupImage(img))
# }
# NOT RUN {
# }
# NOT RUN {
### example: svg -----
library(sp)
data(meuse)
coordinates(meuse) = ~ x + y
proj4string(meuse) = CRS("+init=epsg:28992")
## create plots with points colored according to feature id
library(lattice)
p = xyplot(copper ~ cadmium, data = meuse@data, col = "grey")
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, popup = popupGraph(p, type = "svg"))
### example: png -----
pt = data.frame(x = 174.764474, y = -36.877245)
coordinates(pt) = ~ x + y
proj4string(pt) = "+init=epsg:4326"
p2 = levelplot(t(volcano), col.regions = terrain.colors(100))
mapview(pt, popup = popupGraph(p2, width = 300, height = 400))
### example: html -----
library(scatterD3)
p = lapply(1:length(meuse), function(i) {
clr =rep(0, length(meuse))
clr[[i]] = 1
scatterD3(x = meuse$cadmium,
y = meuse$copper,
col_var = clr,
legend_width = 0)
})
mapview(meuse, popup = popupGraph(p, type = "html", width = 400, height = 300))
mapview(breweries[1, ], map.types = "Esri.WorldImagery",
popup = popupGraph(mapview(breweries[1, ])@map,
type = "html",
width = 500,
height = 400))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab