Skip to content

LayerSwitcher

LayerSwitcher is the layer switcher control. It extends Control. It shows a set of checkboxes on the map to toggle the visibility of base layers and overlay layers. It is displayed by default at the top-right corner.

js
import { LayerSwitcher } from "maptalks";

const layerSwitcher = new LayerSwitcher({
  baseTitle: "Base",
  overlayTitle: "Overlay"
}).addTo(map);

Constructor

js
new LayerSwitcher(options)

Parameters:

  • options — LayerSwitcher control options.

options

NameTypeDescriptionDefault
positionStringThe control position"top-right"
baseTitleStringThe base layer group title'Base Layers'
overlayTitleStringThe overlay layer group title'Layers'
excludeLayersArrayLayers to exclude[]
containerClassStringThe CSS class of the container'maptalks-layer-switcher'

Events

  • layerchange — Fired when layer visibility changes.