geojsonMap | R Documentation |
Simple function like addTiles()
geojsonMap(dat, mapName, namevar=NULL, valuevar=NULL,
palette = "Blues", colorMethod = "numeric",
na.color = "#808080", popup = NULL, stroke = T, smoothFactor = 1,
weight = 1, fillOpacity = 0.7, legendTitle = "Legend", tileType, ...)
dat |
a data.frame contain regions and values |
mapName |
mapName for loading, eg. 'china', 'city', ... |
namevar |
a formula show which feature is chosen for name variable |
valuevar |
a formula show which feature is chosen for value variable |
palette |
The colors or color function that values will be mapped to, see RColorBrewer::display.brewer.all() |
colorMethod |
set one of the coloe mapping in c("numeric", "bin", "quantile", "Factor") |
na.color |
The color to return for NA values. Note that na.color=NA is valid. |
popup |
a character vector of the HTML content for the popups (you are recommended to escape the text using htmlEscape() for security reasons) |
stroke |
whether to draw stroke along the path (e.g. the borders of polygons or circles) |
smoothFactor |
how much to simplify the polyline on each zoom level (more means better performance and less accurate representation) |
weight |
stroke width in pixels |
fillOpacity |
fill opacity |
legendTitle |
legend title |
tileType |
function to define tile like amap or leaflet::addTiles |
... |
other paramter pass to the color mapping function |
dat = data.frame(name = regionNames("china"),
value = runif(34))
geojsonMap(dat,"china")
dat$value2 = cut(dat$value, c(0, 0.25, 0.5, 1))
geojsonMap(dat,"china",
namevar = ~name,
valuevar = ~value2,
palette="Reds",
colorMethod="factor")
geojsonMap(dat,"china",
namevar = ~name,
valuevar = ~value2,
palette = topo.colors(3),
colorMethod="factor")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.