tomroh / leaflegend

Provides extensions to the leaflet R package to customize legends with images, text styling, orientation, sizing, and symbology.
https://leaflegend.delveds.com
Other
34 stars 3 forks source link

Adding Custom Images/Symbols #24

Closed tomroh closed 3 years ago

tomroh commented 3 years ago

The ability to use custom images is not available with makeSizeIcons but it is possible with icons & sizeNumeric.

height <- sizeNumeric(quakes$depth, baseSize = 20)
width <- sizes * 38 / 95
symbols <- icons(
  iconUrl = 'http://leafletjs.com/examples/custom-icons/leaf-green.png',
  iconWidth = width,
  iconHeight = height)
leaflet(quakes) %>%
  addTiles() %>%
  addMarkers(icon = symbols,
             lat = ~lat, lng = ~long) %>%
  addLegendImage(images ="http://leafletjs.com/examples/custom-icons/leaf-green.png",
                 labels = "test",width = 38, height = 95,
                 title = htmltools::tags$div('Leaf',
                 style = 'font-size: 24px; text-align: center;'),
                 position = 'topright')
tomroh commented 3 years ago

e582544666375e70bf12638349b71f1ed2c683fb