From 7542dbcca594a36803ce306477a9928b6c2759cc Mon Sep 17 00:00:00 2001 From: Thomas Roh Date: Thu, 28 Oct 2021 10:55:11 -0700 Subject: [PATCH] adding site --- docs/index.html | 96 ++++++++++++++++------ docs/news/index.html | 1 + docs/pkgdown.yml | 2 +- docs/reference/addLegendAwesomeIcon.html | 2 +- docs/reference/figures/readme-example.png | Bin 0 -> 3342157 bytes 5 files changed, 74 insertions(+), 27 deletions(-) create mode 100644 docs/reference/figures/readme-example.png diff --git a/docs/index.html b/docs/index.html index b439996..4d1e2b9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -115,6 +115,7 @@

@@ -122,32 +123,77 @@

Example

Use addLegend*() to create easily customizable legends for leaflet.

-library(leaflegend)
+
 library(leaflet)
-data(quakes)
-quakes[['group']] <- sample(c('A', 'B', 'C'), nrow(quakes), replace = TRUE)
-factorPal <- colorFactor('Dark2', quakes$group)
-leaflet() %>%
-  addTiles() %>%
-  addCircleMarkers(
-    data = quakes,
-    lat = ~ lat,
-    lng = ~ long,
-    color = ~ factorPal(group),
-    opacity = 1,
-    fillOpacity = 1
-  ) %>%
-  addLegendFactor(
-    pal = factorPal,
-    title = htmltools::tags$div('addLegendFactor', style = 'font-size: 24px; color: red;'),
-    labelStyle = 'font-size: 18px; font-weight: bold;',
-    orientation = 'horizontal',
-    values = quakes$group,
-    position = 'topright',
-    shape = 'triangle',
-    width = 30,
-    height = 30
-  )
+library(leaflegend) +set.seed(22) +data("gadmCHE") +gadmCHE@data$x <- sample(c('A', 'B', 'C'), nrow(gadmCHE@data), replace = TRUE) +factorPal <- colorFactor('Set1', gadmCHE@data$x) +n <- 10 +awesomeMarkers <- data.frame( + marker = sample(c('Font Awesome', 'Ionic', 'Glyphicon'), n, replace = TRUE), + lng = runif(n, gadmCHE@bbox[1,1], gadmCHE@bbox[1,2]), + lat = runif(n, gadmCHE@bbox[2,1], gadmCHE@bbox[2,2]) +) +n2 <- 30 +symbolMarkers <- data.frame( + x = runif(n2, 0, 100), + lng = runif(n2, gadmCHE@bbox[1,1], gadmCHE@bbox[1,2]), + lat = runif(n2, gadmCHE@bbox[2,1], gadmCHE@bbox[2,2]) +) +numericPal <- colorNumeric('inferno', symbolMarkers$marker) +iconSet <- awesomeIconList( + `Font Awesome` = makeAwesomeIcon(icon = "font-awesome", library = "fa", + iconColor = 'gold', markerColor = 'red', + squareMarker = TRUE, + iconRotate = 30, + ), + Ionic = makeAwesomeIcon(icon = "ionic", library = "ion", + iconColor = '#fffff', markerColor = 'blue', + squareMarker = FALSE), + Glyphicon = makeAwesomeIcon(icon = "plus-sign", library = "glyphicon", + iconColor = 'rgb(192, 255, 0)', markerColor = 'darkpurple', + squareMarker = FALSE) +) +baseSize <- 20 +symbols <- makeSizeIcons(value = symbolMarkers$x, + 'plus', + fillColor = numericPal(symbolMarkers$x), + baseSize = baseSize, + opacity = 1, + color = 'black') +leaflet() |> + addTiles() |> + addPolygons(data = gadmCHE, color = ~factorPal(x), + fillOpacity = .5) |> + addAwesomeMarkers(data = awesomeMarkers, lat = ~lat, lng = ~lng, + icon = ~iconSet[marker]) |> + addMarkers(data = symbolMarkers, lat = ~lat, lng = ~lng, icon = symbols) |> + addLegendFactor(pal = factorPal, + shape = 'polygon', + values = gadmCHE@data$x, + title = 'addLegendFactor', + position = 'topright') |> + addLegendAwesomeIcon(iconSet = iconSet, + title = 'addLegendAwesomeIcon', + position = 'bottomleft') |> + addLegendSize(pal = numericPal, + shape = 'plus', + color = 'black', + baseSize = 20, + values = symbolMarkers$x, + orientation = 'horizontal', + title = 'addSizeLegend', + position = 'bottomright') |> + addLegendNumeric(pal = numericPal, + values = symbolMarkers$x, + title = 'addLegendNumeric', + orientation = 'horizontal', + width = 150, + height = 20, + position = 'bottomright')
+

diff --git a/docs/news/index.html b/docs/news/index.html index 048e65e..e43e3b5 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -149,6 +149,7 @@

leaflegend 0.5.0 Unreleased

    +
  • updated example in README

  • adding addLegendAwesomeIcon function to produce legends with markers from awesome icon libraries

  • adding in line and polygon symbol and adding symbols to the README

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index aa71771..fef3703 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 2.14.0.3 pkgdown: 1.6.1 pkgdown_sha: ~ articles: {} -last_built: 2021-10-22T03:41Z +last_built: 2021-10-28T17:54Z urls: reference: https://leaflegend.roh.engineering/reference article: https://leaflegend.roh.engineering/articles diff --git a/docs/reference/addLegendAwesomeIcon.html b/docs/reference/addLegendAwesomeIcon.html index 36d91d0..b8ae9aa 100644 --- a/docs/reference/addLegendAwesomeIcon.html +++ b/docs/reference/addLegendAwesomeIcon.html @@ -244,7 +244,7 @@

Examp style = 'font-size: 20px;', 'Awesome Icons'), labelStyle = 'font-size: 16px;') -

+
#> Error in addLegendAwesomeIcon(addLegendAwesomeIcon(addAwesomeMarkers(addTiles(leaflet(quakes[1:3, ])), lat = ~lat, lng = ~long, icon = iconSet), iconSet = iconSet, orientation = "horizontal", title = htmltools::tags$div(style = "font-size: 20px;", "Awesome Icons"), labelStyle = "font-size: 16px;"), iconSet = iconSet, orientation = "vertical", marker = FALSE, title = htmltools::tags$div(style = "font-size: 20px;", "Awesome Icons"), labelStyle = "font-size: 16px;"): could not find function "addLegendAwesomeIcon"