3

I am searching for a way to lock the size of the circle markers in Leaflet for R, addCircleMarkers(). I need the markers to retain the size they are relative to the polygon they are within upon zooming. At the moment, when you zoom, the markers stay the same size relative to your screen.

3

If I understand what you mean, you use addCircles() instead of addCircleMarkers(). Here's some (totally arbitrary) example code:

#create dummy dataframe
lon <- c(-80, -80.2, -80.4, -80.1, -80.3)
lat <- c(37, 37.05, 37.1, 37, 37.07)
num <- as.numeric(c(6000, 400, 10, 5000, 10))
x <- data.frame(lat, lon, num)

#plot with leaflet
leaflet(data = x) %>%
  addTiles() %>% 
  addCircles(lat = ~lat, lng = ~lon, radius = ~num)

Here's the initial map: enter image description here

And zoomed twice: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.