diff --git a/DESCRIPTION b/DESCRIPTION
index 9faa893..87fd428 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -24,7 +24,10 @@ Imports:
quarto,
readxl,
rmarkdown,
- utils
+ utils,
+ leaflet,
+ leaflegend,
+ tidyr
Suggests:
curl,
knitr,
diff --git a/NAMESPACE b/NAMESPACE
index fbde09b..6cf5e79 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand
export(deployment_gantt)
+export(leaflet_graph)
export(make_receiver_push_summary)
export(make_tag_push_summary)
export(match_map)
diff --git a/R/leaflet_graph.R b/R/leaflet_graph.R
new file mode 100644
index 0000000..76cc9a8
--- /dev/null
+++ b/R/leaflet_graph.R
@@ -0,0 +1,43 @@
+#' Plot the leaflet graphs for detection and individual
+#' @param station_spatial is created by prep_station_spatial,which is a spatial object with the geometry
+#' @export
+
+leaflet_graph <- function(station_spatial) {
+ geometry<- NULL
+ df <- station_spatial |> tidyr::extract(geometry, c('lon', 'lat'), '\\((.*), (.*)\\)', convert = TRUE)
+ numPal <- leaflet::colorNumeric('viridis', df $Detections)
+ leaflet::leaflet(data = df) |>
+ leaflet::addTiles() |>
+ leaflet::addCircleMarkers( lat = ~lat, lng = ~lon,
+ color= ~numPal(Detections), fillColor = ~numPal(Detections),fillOpacity = 0.7,
+ popup = paste("Station ", df$station , "
",
+ "PI:", df$PI, "
",
+ "Detections:", df$Detections, "
",
+ "detectedby:", df$detectedby, "
",
+ "Individuals:", df$Individuals),
+ radius = ~Individuals) |>
+
+ leaflegend::addLegendSize(
+ values = df $Individuals,
+ baseSize = 1,
+ color = 'black',
+ title = 'Individual',
+ shape = 'circle',
+ orientation = 'horizontal',
+ opacity = .5,
+ fillOpacity = 0,
+ breaks = 5,
+ position = 'bottomright') |>
+ leaflegend::addLegendNumeric(
+ pal = numPal,
+ title = 'Matched Detection',
+ shape = 'stadium',
+ values = df $Detections,
+ fillOpacity = .5,
+ decreasing = TRUE,
+ position = 'bottomright')
+
+
+
+}
+
diff --git a/inst/qmd_template/make_tag_push_summary.qmd b/inst/qmd_template/make_tag_push_summary.qmd
index 83bc5a4..7857ae8 100644
--- a/inst/qmd_template/make_tag_push_summary.qmd
+++ b/inst/qmd_template/make_tag_push_summary.qmd
@@ -23,10 +23,8 @@ knitr::opts_chunk$set(
```{r}
#| label: packages
#| message: false
-
-library(otndo)
library(data.table)
-library(mapview)
+library(otndo)
library(reactable)
```
@@ -226,18 +224,15 @@ reactable(new_station_summary)
```{r}
#| label: new-detection-map-leaflet
-#| fig-cap: Figure 7. Number of newly-added detections per receiver. Points represent receiver locations, while size and color reflect the number of detections at that location.
+#| fig-cap: Figure 7. Number of newly-added detections per receiver. Points represent receiver locations, where color reflects the number of detections and size reflects the number of fish at that location.
#| eval: !expr "nrow(new_matches) > 0"
-new_station_spatial <- prep_station_spatial(new_matches, type = "tag")
-
-mapview::mapview(new_station_spatial,
- zcol = "Detections",
- cex = "Individuals",
- layer.name = "Matched detections"
-)
+leaflet_graph(station_spatial)
```
+
+
+
```{r results='asis', echo=FALSE}
if (is.null(params$since)) {
cat("-->")
diff --git a/man/leaflet_graph.Rd b/man/leaflet_graph.Rd
new file mode 100644
index 0000000..d679ce7
--- /dev/null
+++ b/man/leaflet_graph.Rd
@@ -0,0 +1,14 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/leaflet_graph.R
+\name{leaflet_graph}
+\alias{leaflet_graph}
+\title{Plot the leaflet graphs for detection and individual}
+\usage{
+leaflet_graph(station_spatial)
+}
+\arguments{
+\item{station_spatial}{is created by prep_station_spatial,which is a spatial object with the geometry}
+}
+\description{
+Plot the leaflet graphs for detection and individual
+}