View source: R/google_map_layer_geojson.R
update_geojson | R Documentation |
Updates a geojson layer by a specified style. Designed to work within an interactive environment (e.g. shiny)
update_geojson(map, layer_id = NULL, style)
map |
a googleway map object created from |
layer_id |
single value specifying an id for the layer. |
style |
Style options for the geoJSON. See details |
The style object can either be a valid JSON string, or a named list. The style object will contain the following fields
property : the property of the geoJSON that contains the value
value : the value of the geoJSON that identifies the feature to be updated
features : a list (or JSON object) of features to be updated
see add_geojson for valid features
## Not run:
style <- paste0('{
"property" : "AREASQKM",
"value" : 5,
"operator" : ">=",
"features" : {
"fillColor" : "red",
"strokeColor" : "red"
}
}')
google_map(key = map_key) %>%
add_geojson(data = geo_melbourne) %>%
update_geojson(style = style)
lst_style <- list(property = "AREASQKM", operator = "<=", value = 5,
features = list(fillColor = "red",
strokeColor = "red"))
google_map(key = map_key) %>%
add_geojson(data = geo_melbourne) %>%
update_geojson(style = lst_style)
## Styling a specific feature
style <- '{"property" : "SA2_NAME", "value" : "Abbotsford", "features" : { "fillColor" : "red" } }'
google_map(key = map_key) %>%
add_geojson(data = geo_melbourne) %>%
update_geojson(style = style)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.