geojsonMap: Load amap to leaflet

Description Usage Arguments Examples

View source: R/geojsonMap.R

Description

Simple function like addTiles()

Usage

1
2
3
4
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, ...)

Arguments

dat

a data.frame contain regions and values

mapName

mapName for loading, eg. 'china', 'city', ...

namevar

show which feature is chosen for name variable

valuevar

show which featue 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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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")

Example output



leafletCN documentation built on May 1, 2019, 9:21 p.m.