Remove elements from a map
Remove one or more features from a map, identified by
clear all features of the given type or group.
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 27 28 29 30 31 32 33 34 35
removeControl(map, layerId) clearControls(map) clearGroup(map, group) removeImage(map, layerId) clearImages(map) removeTiles(map, layerId) clearTiles(map) removePopup(map, layerId) clearPopups(map) removeMarker(map, layerId) clearMarkers(map) removeMarkerCluster(map, layerId) clearMarkerClusters(map) removeMarkerFromCluster(map, layerId, clusterId) removeShape(map, layerId) clearShapes(map) removeGeoJSON(map, layerId) clearGeoJSON(map)
a map widget object, possibly created from
character vector; the layer id(s) of the item to remove
the name of the group whose members should be removed
the id of the marker cluster layer
When used with a
leaflet() map object, these functions
don't actually remove the features from the map object, but simply add an
operation that will cause those features to be removed after they are
added. In other words, if you add a polygon
"foo" and the call
removeShape("foo"), it's not smart enough to prevent the polygon
from being added in the first place; instead, when the map is rendered, the
polygon will be added and then removed.
For that reason, these functions aren't that useful with
objects and are really intended to be used with
WMS tile layers are extensions of tile layers, so they can also be removed
or cleared via
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.