Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

remove

Remove elements from a map


Description

Remove one or more features from a map, identified by layerId; or, clear all features of the given type or group.

Usage

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)

removeMeasure(map)

removeTopoJSON(map, layerId)

clearTopoJSON(map)

Arguments

map

a map widget object, possibly created from leaflet() but more likely from leafletProxy()

layerId

character vector; the layer id(s) of the item to remove

group

the name of the group whose members should be removed

clusterId

the id of the marker cluster layer

Value

the new map object

Note

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 leaflet map objects and are really intended to be used with leafletProxy instead.

WMS tile layers are extensions of tile layers, so they can also be removed or cleared via removeTiles() or clearTiles().


leaflet

Create Interactive Web Maps with the JavaScript 'Leaflet' Library

v2.0.4.1
GPL-3
Authors
Joe Cheng [aut, cre], Bhaskar Karambelkar [aut], Yihui Xie [aut], Hadley Wickham [ctb], Kenton Russell [ctb], Kent Johnson [ctb], Barret Schloerke [ctb], jQuery Foundation and contributors [ctb, cph] (jQuery library), Vladimir Agafonkin [ctb, cph] (Leaflet library), CloudMade [cph] (Leaflet library), Leaflet contributors [ctb] (Leaflet library), Brandon Copeland [ctb, cph] (leaflet-measure plugin), Joerg Dietrich [ctb, cph] (Leaflet.Terminator plugin), Benjamin Becquet [ctb, cph] (Leaflet.MagnifyingGlass plugin), Norkart AS [ctb, cph] (Leaflet.MiniMap plugin), L. Voogdt [ctb, cph] (Leaflet.awesome-markers plugin), Daniel Montague [ctb, cph] (Leaflet.EasyButton plugin), Kartena AB [ctb, cph] (Proj4Leaflet plugin), Robert Kajic [ctb, cph] (leaflet-locationfilter plugin), Mapbox [ctb, cph] (leaflet-omnivore plugin), Michael Bostock [ctb, cph] (topojson), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.