removeLayer(
id:string):this
Defined in: ui/map.ts:3577
Removes the layer with the given ID from the map's style.
An ErrorEvent will be fired if no such layer exists.
Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string |
The ID of the layer to remove |
Returns
this
Example
If a layer with ID 'state-data' exists, remove it.
if (map.getLayer('state-data')) map.removeLayer('state-data');