Description Usage Arguments Value Author(s) See Also Examples
Augment a Leaflet web map with additional elements.
The AddHomeButton
function adds a button that zooms to the initial map extent.
The AddClusterButton
function adds a button that toggles marker clusters on and off.
The AddSearchButton
function adds a control that may be used to search markers/features location by property.
And the AddCircleLegend
function adds a map legend.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | AddHomeButton(map, extent = NULL, position = "topleft")
AddClusterButton(map, clusterId, position = "topleft")
AddSearchButton(
map,
group,
propertyName = "label",
zoom = NULL,
textPlaceholder = "Search...",
openPopup = FALSE,
position = "topleft"
)
AddLegend(
map,
labels,
colors,
radius,
opacity = 0.5,
symbol = c("square", "circle"),
title = "EXPLANATION",
position = "topright"
)
|
map |
'leaflet'. Map widget object |
extent |
'Spatial*', 'Raster*', 'Extent', 'matrix', or 'numeric' vector.
Extent object (or object from which an |
position |
'character' string.
Position of the button on the web map.
Possible values are |
clusterId |
'character' string. Identification for the marker cluster layer. |
group |
'character' string. Name of the group whose features will be searched. |
propertyName |
'character' string.
Property name used to describe markers, such as, |
zoom |
'integer' count. Zoom level for move to location after marker found in search. |
textPlaceholder |
'character' string. Message to show in search element. |
openPopup |
'logical' flag. Whether to open the marker popup associated with the searched for marker. |
labels |
'character' vector. Labels in the legend. |
colors |
'character' vector.
HTML colors corresponding to |
radius |
'numeric' number. Border radius of symbols in the legend, in pixels. |
opacity |
'numeric' number. Opacity of symbols in the legend, from 0 to 1. |
symbol |
'character' string.
Symbol type in the legend, either |
title |
'character' string. Legend title |
An object of class 'leaflet'.
A new map
object with added element.
J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | city <- rgdal::readOGR(system.file("extdata/city.geojson",
package = "inlmisc")[1])
opt <- leaflet::markerClusterOptions(showCoverageOnHover = FALSE)
map <- CreateWebMap("Topo")
map <- leaflet::addMarkers(map, label = ~name, popup = ~name,
clusterOptions = opt,
clusterId = "cluster",
group = "marker", data = city)
map <- AddHomeButton(map)
map <- AddClusterButton(map, clusterId = "cluster")
map <- AddSearchButton(map, group = "marker", zoom = 15,
textPlaceholder = "Search city names...")
map
labels <- c("Non-capital", "Capital")
colors <- c("green", "red")
fillColor <- colors[(city@data$capital > 0) + 1]
map <- CreateWebMap("Topo")
map <- leaflet::addCircleMarkers(map, radius = 6, color = "white",
weight = 1, opacity = 1,
fillColor = fillColor,
fillOpacity = 1, fill = TRUE,
data = city)
map <- AddLegend(map, labels = labels, colors = colors, radius = 5,
opacity = 1, symbol = "circle")
map
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.