
Add image query functionality to leaflet/mapview map.
addImageQuery(map, x, group = NULL, layerId = NULL, project = TRUE,
type = c("mousemove", "click"), digits, position = "topright", ...)
the map with the RasterLayer to be queried.
the RasterLayer that is to be queried.
the group of the RasterLayer to be queried.
the layerId of the RasterLayer to be queried. Needs to be the
same a supplied in addRasterImage
.
whether to project the RasterLayer to conform with leaflets
expected crs. Defaults to TRUE
and things are likely to go haywire
if set to FALSE
.
whether query should occur on 'mousemove' or 'click'. Defaults to 'mousemove'.
the number of digits to be shown in the display field.
where to place the display field. Default is 'topright'.
currently not used.
A leaflet map object.
This function enables Raster* objects added to leaflet/mapview maps to be
queried. Standard query is on 'mousmove', but can be changed to 'click'.
Note that for this to work, the layerId
needs to be the same as the
one that was set in addRasterImage
. Currently only works for
numeric values (i.e. numeric/integer and factor values are supported).
# NOT RUN {
library(leaflet)
library(mapview)
leaflet() %>%
addProviderTiles("OpenStreetMap") %>%
addRasterImage(poppendorf[[1]], project = TRUE, group = "poppendorf",
layerId = "poppendorf") %>%
addImageQuery(poppendorf[[1]], project = TRUE,
layerId = "poppendorf") %>%
addLayersControl(overlayGroups = "poppendorf")
# }
Run the code above in your browser using DataLab