setLayerVisibility

Sets the visibility for the specified layer name, for all layer types: Polyline, Polygon and Marker.

If the name of the layer exists in each type, all of the same name will change.
ex:
If you have 2 “default” layers one in polyline and one in marker, setting a layer name of “default” to false will hide both.

Parameters:

  • layerName (string): The name of the layer to update

  • visible (boolean): If true, then show the layer; if false, then hide the layer

Returns: Nothing

Throws: Error in the console if a layer is not found with a name that matches layerName.

Code Sample