Add a color legend for a heatmap
Usage
addHeatmapLegend(
map,
values,
colors = NULL,
max = NULL,
title = "Intensity",
position = "bottomright",
layerId = NULL,
opacity = 1,
...
)Arguments
- map
a map widget object created from
leaflet()- values
numeric intensity values. The legend goes from 0 to
max, matching how Leaflet.heat colorsintensity / max.- colors
a color palette name, a vector of colors, a
colorNumericfunction, or a WebGLgradientTexturename such as"skyline"or"OrRd". The default matches the Leaflet.heat blue-cyan-lime-yellow-red ramp.- max
upper end of the legend. Defaults to the maximum of
values.- title
legend title
- position
the position of the legend
- layerId
the ID of the legend; subsequent calls to
addLegendoraddControlwith the samelayerIdwill replace this legend. The ID can also be used withremoveControl.- opacity
legend opacity
- ...
additional arguments passed to
addLegend
Examples
leaflet(quakes) %>%
addProviderTiles(providers$CartoDB.DarkMatter) %>%
addHeatmap(lng = ~long, lat = ~lat, intensity = ~mag) %>%
addHeatmapLegend(values = quakes$mag, title = "Magnitude")