Leaflet zoomify circles6/22/2023 That means that the number of clusters shown will depend on how big the map is, in pixels. Worth noting that the radius is measured in pixels as the map is currently being displayed. If you have the default setting of showing the coverage area when hovering over a marker, it should help with figuring out the radius you want. Larger radius = fewer clusters: leaflet(car_burglaries) %>%ĬlusterOptions = markerClusterOptions(maxClusterRadius = 200) Smaller radius = more clusters: leaflet(car_burglaries) %>%ĬlusterOptions = markerClusterOptions(maxClusterRadius = 50) The default radius of 80 pixels: leaflet(car_burglaries) %>% So I messed around with a couple options. You can also use a function that accepts the current map zoom and returns the maximum cluster radius in pixels. Decreasing will make more, smaller clusters. The maximum radius that a cluster will cover from the central marker (in pixels). The markercluster docs say there's an argument maxClusterRadius: For clustering, you were right to notice that markerClusterOptions will pass on more advanced options. will be passed to the underlying javascript libraries, but to use these, it's helpful to know your way around the javascript docs. Many functions in the R leaflet package mention that additional arguments in. The R leaflet package docs mention that clustering is done via a plugin for the Leaflet javascript library called Leaflet.markercluster, documented here. Popup = ~paste(as.character(incident_datetime),",","Case number",as.character(case_number)), Leaflet(car_burglaries) %>% addTiles() %>% Mutate(datetime=mdy_hms(incident_datetime)) %>% I don't want to use freezeAtZoom because then users won't be able to zoom in and see each individual observation.ĭata procured from: library(tidyverse) library(leaflet) library(lubridate)Ĭrime_reports % filter(incident_type_primary="VEHICLE BURGLARY") %>% However it would be nice if there were at least twice as many clusters at default zoom. Is there a parameter in markerClusterOptions() that controls the number of groups based on the zoom level? For example, at default zoom my map shows just 3 clusters for 1800 observations. Making a leaflet map with clustered markers.
0 Comments
Leave a Reply. |