Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding pkgdown site #29

Merged
merged 15 commits into from
Jul 23, 2021
91 changes: 46 additions & 45 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
# leaflegend 0.4.0

* fixes error on makeSizeLegend where fillColor is not evaluated if no argument is provided

* adding colorValues as an argument to makeSizeLegend so that symbols can be sized and colored on different vectors of data

* fixes warning on addLegendNumeric where the shape default was a vector not a single value

* adding number formatting to addSizeLegend

* adding group layer support for legends. Use addLayersControl to turn on/off
legends

* added an example to show how to use a raster image with size encodings

# leaflegend 0.3.0

* stroke outlines of shapes are now padded so that the stroke is not cut off

* numeric legends now have appropriate sizing for text

* star symbol outline has been fixed

* new function `makeSizeIcons` as a convenience wrapper size scaled symbols

# leaflegend 0.2.0

* new functions `addLegendSize`, `sizeNumeric`, and `sizeBreaks` were added to allow encoding size on symbols.

* `addLegendImage` supports multiple height and width paramaters for images where you want different sizes

* `addLegendImage` now supports using an svg URI from the output of `makeSymbol`.
To supply a custom svg URI, add the 'svgURI' class to the character vector.

* added more shapes to `makeSymbol`, `addLegendNumeric`,
`addLegendQuantile`, `addLegendFactor`, `addLegendBin`

* Control the opacity of the legend shapes for `addLegendNumeric`,
`addLegendQuantile`, `addLegendFactor`, `addLegendBin`

* `makeSymbol` now returns embeddable svg

# leaflegend 0.1.0

* Added a `NEWS.md` file to track changes to the package.
# leaflegend 0.4.0

* fixes error on makeSizeLegend where fillColor is not evaluated if no argument is provided

* adding colorValues as an argument to makeSizeLegend so that symbols can be sized and colored on different vectors of data

* fixes warning on addLegendNumeric where the shape default was a vector not a single value

* adding number formatting to addSizeLegend

* adding group layer support for legends. Use addLayersControl to turn on/off
legends

* added example for using raster images with size encodings based on data


# leaflegend 0.3.0

* stroke outlines of shapes are now padded so that the stroke is not cut off

* numeric legends now have appropriate sizing for text

* star symbol outline has been fixed

* new function `makeSizeIcons` as a convenience wrapper size scaled symbols

# leaflegend 0.2.0

* new functions `addLegendSize`, `sizeNumeric`, and `sizeBreaks` were added to allow encoding size on symbols.

* `addLegendImage` supports multiple height and width paramaters for images where you want different sizes

* `addLegendImage` now supports using an svg URI from the output of `makeSymbol`.
To supply a custom svg URI, add the 'svgURI' class to the character vector.

* added more shapes to `makeSymbol`, `addLegendNumeric`,
`addLegendQuantile`, `addLegendFactor`, `addLegendBin`

* Control the opacity of the legend shapes for `addLegendNumeric`,
`addLegendQuantile`, `addLegendFactor`, `addLegendBin`

* `makeSymbol` now returns embeddable svg

# leaflegend 0.1.0

* Added a `NEWS.md` file to track changes to the package.
45 changes: 25 additions & 20 deletions R/legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,27 @@
#' group = 'Quake Leaves') %>%
#' addLayersControl(overlayGroups = c('Quake Leaves'), position = 'bottomright')
#'
#' # Add a legend with different size custom images to match using size encoding
#' # on icons
#' height <- sizeNumeric(quakes$depth, baseSize = 40)
#' width <- height * 38 / 95
#' symbols <- icons(
#' iconUrl = 'http://leafletjs.com/examples/custom-icons/leaf-green.png',
#' iconWidth = width,
#' iconHeight = height)
#' probs <- c(.2, .4, .6, .8)
#' leaflet(quakes) %>%
#' addTiles() %>%
#' addMarkers(icon = symbols,
#' lat = ~lat, lng = ~long) %>%
#' addLegendImage(images = rep("http://leafletjs.com/examples/custom-icons/leaf-green.png", 4),
#' labels = round(quantile(height, probs = probs), 0),
#' width = quantile(height, probs = probs) * 38 / 95,
#' height = quantile(height, probs = probs),
#' title = htmltools::tags$div('Leaf',
#' style = 'font-size: 24px; text-align: center;'),
#' position = 'topright', orientation = 'vertical')
#' # use raster images with size encodings
#' height <- sizeNumeric(quakes$depth, baseSize = 40)
#' width <- height * 38 / 95
#' symbols <- icons(
#' iconUrl = 'http://leafletjs.com/examples/custom-icons/leaf-green.png',
#' iconWidth = width,
#' iconHeight = height)
#' probs <- c(.2, .4, .6, .8)
#' leaflet(quakes) %>%
#' addTiles() %>%
#' addMarkers(icon = symbols,
#' lat = ~lat, lng = ~long) %>%
#' addLegendImage(
#' images = rep("http://leafletjs.com/examples/custom-icons/leaf-green.png", 4),
#' labels = round(quantile(height, probs = probs), 0),
#' width = quantile(height, probs = probs) * 38 / 95,
#' height = quantile(height, probs = probs),
#' title = htmltools::tags$div(
#' 'Leaf',
#' style = 'font-size: 24px; text-align: center; margin-bottom: 5px;'),
#' position = 'topright', orientation = 'vertical')
addLegendImage <- function(map,
images,
labels,
Expand All @@ -124,6 +125,9 @@ addLegendImage <- function(map,
} else {
htmlTag <- htmltools::tags$span
}
if ( inherits(images, 'svgURI') ) {
images <- list(images)
}
htmlElements <- Map(
img = images,
label = labels,
Expand Down Expand Up @@ -688,6 +692,7 @@ addLegendNumeric <- function(map,
x2 <- 1
}
labels <- numberFormat(labels)
#fontSize <- as.numeric(sub('.*(font-size: )([0-9]+)(px).*', '\\2', labelStyle))
labelStyle <- ''
cexAdj <- 1#fontSize / 14
textWidth <- max(graphics::strwidth(labels, units = 'inches', cex = cexAdj)) * 72
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# leaflegend <a href='https://leaflegend.roh.engineering'><img src='man/figures/logo.png' align="right" height="106" /></a>

<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/leaflegend)](https://CRAN.R-project.org/package=leaflegend)
[![R-CMD-check](https://github.com/tomroh/leaflegend/workflows/R-CMD-check/badge.svg)](https://github.com/tomroh/leaflegend/actions)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![](https://cranlogs.r-pkg.org/badges/grand-total/leaflegend?color=green)](https://cran.r-project.org/package=leaflegend)
<!-- badges: end -->


# leaflegend

This package provides extensions to the leaflet package to
customize leaflet legends without adding an outside css file to the output
to style legends. The legend extensions allow the user to add images to
Expand All @@ -27,6 +27,11 @@ Install the development version with:
```r
devtools::install_github("tomroh/leaflegend")
```
## Tutorials

* [Introduction to leaflegend](https://roh.engineering/posts/2021/02/introduction-to-leaflegend/)

* [Map Symbols and Size Legends](https://roh.engineering/posts/2021/05/map-symbols-and-size-legends-for-leaflet/)

## Example

Expand Down Expand Up @@ -61,9 +66,6 @@ leaflet() %>%
)
```

## Tutorials

* [Introduction to leaflegend](https://roh.engineering/posts/2021/02/introduction-to-leaflegend/)

* [Map Symbols and Size Legends](https://roh.engineering/posts/2021/05/map-symbols-and-size-legends-for-leaflet/)

10 changes: 9 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
url: https://leaflegend.roh.engineering
authors:
Thomas Roh:
href: https://roh.engineering/about
template:
params:
bootswatch: readable
url: https://leaflegend.roh.engineering
docsearch:
api_key: 89d2953b5dfa27a60dd7d7bec9e087fa
index_name: roh
opengraph:
twitter:
creator: "@rstatengineer"
card: summary_large_image

37 changes: 37 additions & 0 deletions docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading