View source: R/leaflet_geopos.r
leaflet_geopos | R Documentation |
This function creates a Leaflet map widget using htmlwidgets from spatial tagging data. The widget can be rendered on HTML pages generated from R Markdown, Shiny, or other applications.
leaflet_geopos(data, ID_label, add_label=NULL, except_label=NULL,
collapsedLayers=TRUE, radius=1000, pal,
layer_title=ID_label, colorby="date", cb.title, cbpos="bottomright",
showScaleBar=TRUE, showSlideBar=FALSE)
data |
spatial data such as data.frame or SpatialPolygonsDataFrame. |
ID_label |
Vector in spatial data that defines the ID of the tracks to be plotted. |
add_label, except_label |
additional labels or labels to be removed from hover. |
collapsedLayers |
whether to collapse leaflet layer legend. |
radius |
circle size, in case of simple Lon/Lat tracking dataframes. |
pal |
color map to be plotted in case of polygon (.nc-files) or scatter plots (default is the 'jet'-colormap, and 'year.jet' in case |
layer_title |
character string indicating the title of the layer legend (by default defined by |
colorby |
character string indicating the vector for which to apply the colorbar (by default |
cb.title |
character string indicating the title of the colorbar (by default inferred from |
cbpos |
position of the colorbar (by default |
showScaleBar, showSlideBar |
whether to show the scale bar or the slide bar. |
Robert K. Bauer
ggplotly_geopos, ggplot_geopos, update_leaflet_elementId
# csv_file <- system.file("example_files/15P1019-104659-1-GPE3.csv",package="RchivalTag")
# s0 <- get_geopos(csv_file)
# ggplot_geopos(s0)
# leaflet_geopos(s0,ID_label="DeployID")
# leaflet_geopos(s0,ID_label="DeployID",showSlideBar = T)
#
# kmz_file <- system.file("example_files/15P1019-104659-1-GPE3.kmz",package="RchivalTag")
# k1 <- get_geopos(kmz_file)
# kmz_file2 <- system.file("example_files/15P0986-15P0986-2-GPE3.kmz",package="RchivalTag")
# k2 <- get_geopos(kmz_file2)
# k0 <- k3 <- rbind(k1,k2)
# ggplot_geopos(k0,ggobj = ggplotmap("lion"))
#
# # ggobj <- ggplot_geopos(k1)
# # ggplot_geopos(ggobj = ggobj,k2)
# leaflet_geopos(k0,ID_label="DeployID",collapsedLayers = F) %>% addMiniMap()
# leaflet_geopos(k0,ID_label="DeployID",showSlideBar = T)
#
## Code to illustrate how to avoid rendering issues in RMarkdown:
## only valid in RMarkdown chunks:
# kmz_file2 <- system.file("example_files/15P0986-15P0986-2-GPE3.kmz",package="RchivalTag")
# k2 <- get_geopos(kmz_file2)
# k0 <- k3 <- rbind(k1,k2)
#
# library(leaflet)
# map <- leaflet_geopos(k0, ID_label="DeployID", collapsedLayers = F)
# map
# map # plot again to show rendering issues (in the layer menu title)
## this is required to avoid rendering issues when plotting the same map twice via RMarkdown
# map <- update_leaflet_elementId(map)
#
# plot again with updated elementID:
# map %>% addMiniMap()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.