Created
September 8, 2017 05:48
-
-
Save tim-salabim/bc8e90c0a0391d78c6c2ebd97690b995 to your computer and use it in GitHub Desktop.
add minichart to layers control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(mapview) | |
library(leaflet.minicharts) | |
library(sf) | |
val1 = sample.int(10, nrow(franconia), replace = TRUE) | |
val2 = round(val1 * runif(nrow(franconia), 0.3, 1), 0) | |
mat = cbind(val1, val2) | |
pal = c("darkred", "lightgreen") | |
m = mapview(franconia)@map | |
m %>% | |
addMinicharts(lng = st_coordinates(st_centroid(franconia))[, "X"], | |
lat = st_coordinates(st_centroid(franconia))[, "Y"], | |
chartdata = mat, type = "pie", showLabels = TRUE, | |
layerId = as.character(1:nrow(franconia)), | |
colorPalette = pal, legend = FALSE) %>% | |
addLayersControl(overlayGroups = c("franconia", "minicharts")) %>% | |
onRender("var minilayer = this._map.layerManager._byCategory.minichart; | |
this._map.layerManager.addLayer(minilayer, null, null, minicharts);") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment