diff --git a/DESCRIPTION b/DESCRIPTION index 176442f..1c184c1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,7 +13,8 @@ Suggests: knitr, kableExtra, leaflet, - leafem, + leafem, + htmltools, dplyr, rmarkdown VignetteBuilder: knitr diff --git a/vignettes/Interactive-map.Rmd b/vignettes/Interactive-map.Rmd index 0a8aaaa..cf81e47 100644 --- a/vignettes/Interactive-map.Rmd +++ b/vignettes/Interactive-map.Rmd @@ -26,6 +26,7 @@ library(leafem) library(sf) library(knitr) library(kableExtra) +library(htmltools) ``` Use the interactive map below to check population changes. Zoom in to see where *Podocnemis unilfilis* is Endangered based on IUCN Redlist criteria - A3bd. @@ -46,6 +47,10 @@ points_bau4326 <- points_bau |> filter(row_number() %% 5 == 1) |> st_as_sf(crs = 3395) |> st_transform(4326) levels(points_bau4326$flag_50_42y) <- c("No", "Yes") points_bau4326_low <- points_bau4326 +# label to plot with circle +points_bau4326_low$label <- paste("Prot = ", points_bau4326_low$Protected, + "Acc = ", points_bau4326_low$Accessible, + "Free = ", points_bau4326_low$Free.flowing) # colour palette leaf_pal <- colorFactor( palette = c("#7274C1", "#A3720E"), @@ -78,10 +83,14 @@ basemap <- leaflet::leaflet() %>% position = "topleft" ) -# interactive map -leaflet::leaflet(points_bau4326_low) |> - addTiles() |> +# interactive map. Optins added to make panning smoother.... +leaflet::leaflet(points_bau4326_low, + options = leafletOptions(preferCanvas = TRUE)) |> + addTiles(options = tileOptions( + updateWhenZooming = FALSE, # map won't update tiles until zoom is done + updateWhenIdle = TRUE)) |> addCircles(color = ~leaf_pal(flag_50_42y), + popup = ~htmlEscape(label), group = "points_bau4326_low" ) |> addCircleMarkers(color = ~leaf_pal(flag_50_42y),