GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - jack-davison/leaf.magic: 📍 R package for more customisable marker icons in R Leaflet

BranchesTags
Open more actions menu

Latest commit

 

History

62 Commits
62 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
R
R
 
 
data-raw
data-raw
 
 
data
data
 
 
inst
inst
 
 
man
man
 
 
pkgdown
pkgdown
 
 
tests
tests
 
 
vignettes
vignettes
 
 
.Rbuildignore
.Rbuildignore
 
 
.gitignore
.gitignore
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
DESCRIPTION
DESCRIPTION
 
 
LICENSE
LICENSE
 
 
LICENSE.md
LICENSE.md
 
 
NAMESPACE
NAMESPACE
 
 
NEWS.md
NEWS.md
 
 
README.md
README.md
 
 
_pkgdown.yml
_pkgdown.yml
 
 
leaf.magic.Rproj
leaf.magic.Rproj
 
 

Repository files navigation

{leaf.magic} - Use Modern Icon Libraries in Leaflet Markers leaf.magic website

CRAN status R-CMD-check

The goal of {leaf.magic} is to overcome the somewhat outdated "Font Awesome" implementation in vanilla R {leaflet} by constructing SVG markers on the fly using modern icon libraries such as {fontawesome}, {bsicons} and {lucidr}. There are a few issues {leaf.magic} sets out to overcome:

  • leaflet::awesomeIcons() is limited to Font Awesome 4 👎

  • leaflet::awesomeIcons() is limited to a handful of discrete colours 👎

  • leaflet::awesomeIcons() is limited to a single marker size and shape 👎

  • Vanilla {leaflet} doesn't provide any additional features to construct legends, icon palettes, or such like 👎

{leaf.magic} attempts to solve all of this:

  • magicIcons() uses up-to-date versions of Font Awesome, Bootstrap, Lucide, and Ionicons icons - or your own text and SVG icons ✅

  • magicIcons() draws its own vector markers, so they can be any colour, size or shape (including shapes you design yourself) and stay sharp at any size ✅

  • {leaf.magic} exports functions like iconFactor() and addIconLegend() to map data to icons and explain them to users, just like colours in {leaflet} ✅

Installation

You can install the development version of {leaf.magic} like so:

# install.packages("pak")
pak::pak("jack-davison/leaf.magic")

Example

Pass magicIcons() to the icon argument of leaflet::addMarkers(). Like leaflet::awesomeIcons(), its arguments can be formulas, which are evaluated using the map's data.

library(leaflet)
library(leaf.magic)

iconPal <- iconFactor(c("city", "industry", "car"), domain = port_talbot$site_type)
colPal <- colorFactor(c("#12436D", "#28A197", "#801650"), domain = port_talbot$site_type)

leaflet(port_talbot) |>
  addTiles() |>
  addMarkers(
    icon = magicIcons(
      icon = ~ iconPal(site_type),
      markerColor = ~ colPal(site_type),
      marker = ~ ifelse(open, "marker", "circle")
    ),
    popup = ~site
  ) |>
  addIconLegend(
    pal = iconPal,
    values = ~site_type,
    colors = colPal,
    title = "Site Type"
  )

A map of air quality monitoring sites in Port Talbot, using {leaf.magic} markers which show the type of each site with both an icon and a colour.

{leaf.magic} is thoroughly documented on the package website. Start with the getting started guide, then see the articles on customising markers and icon scales & legends.

Attributions

{leaf.magic} is licensed under the MIT License, and would not be possible without the following icon libraries:

  • Font Awesome - Website | License | R Package {fontawesome}

  • Bootstrap Icons - Website | License | R Package {bsicons}

  • Lucide - Website | License | R Package {lucidr}

  • Ionicons - Website | License

Code of Conduct

Please note that the leaf.magic project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

About

📍 R package for more customisable marker icons in R Leaflet

jack-davison.github.io/leaf.magic/

Topics

leafletpackagerrstats

Resources

Readme

Code of conduct

Code of conduct

Contributing

Contributing
Activity

Stars

10 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.