The plugin allows to avoid cluttering in marker labels and gives priority to labels of your choice (with higher weight).
Arguments
- map
A map widget object created from
leaflet
- group
The group name of the layer/s for which label collisions are to be avoided. To see the effects of this plugin the
labelOptions
of the markers must be configured with eitherpermanent = TRUE
ornoHide = TRUE
.- weight
An optional weight for markers. If a vector is given, the length should match the number of all markers in the corresponding groups. If a numeric value is specified, it is used for each marker and thus no prioritization of the labels takes place. In all other cases a random integer is calculated.
- entries
A numeric value, a higher value relates to faster insertion and slower search, and vice versa. The default is 10
Note
It is important to invoke the function after the markers have been added to the map. Otherwise nothing will happen.
Examples
library(leaflet)
library(leaflet.extras2)
leaflet() %>%
addTiles() %>%
addMarkers(
data = breweries91,
label = ~brewery,
group = "markers",
labelOptions = labelOptions(permanent = TRUE)
) %>%
addLabelgun("markers", 1)