Reputation: 703
Does somenone know if it is possible to reduce the size of R leaflet markers?
Please find below a reproductible example
library(leaflet)
leaflet(data = quakes[1:80,]) %>% addTiles() %>%
addAwesomeMarkers(~long, ~lat, popup = ~as.character(mag), label = ~as.character(mag))
I would like to reduce the size of these markers in order to distinguish them better. Any suggestion?
Upvotes: 3
Views: 6385
Reputation: 1431
The R Leaflet docs have a section on customising marker icons.
They show that if you point to an image (you are currently pointing to the default image) then you can adjust the size and location parameters. Here is the code they give:
greenLeafIcon <- makeIcon(
iconUrl = "http://leafletjs.com/examples/custom-icons/leaf-green.png",
iconWidth = 38, iconHeight = 95,
iconAnchorX = 22, iconAnchorY = 94,
shadowUrl = "http://leafletjs.com/examples/custom-icons/leaf-shadow.png",
shadowWidth = 50, shadowHeight = 64,
shadowAnchorX = 4, shadowAnchorY = 62
)
leaflet(data = quakes[1:4,]) %>% addTiles() %>%
addMarkers(~long, ~lat, icon = greenLeafIcon)
So if you point to the image you want and reduce the iconWidth
value you should achieve what you asked for.
Upvotes: 1