This is a default map without layers and overlays control

This is a map with different base layers and overlays

In this example a layer model is defined. A layer model is defined by objects containing the properties of the layers.
The base layers are defined in the baselayers object and the overlays object inside the layers definition:

layers: {
    baselayers: {
        mapOne: {... map properties ...},
        mapTwo: {... map properties ...},
        ...
        mapN: {... map properties ...}
    },
    overlays: {
        overlayOne: {... overlay properties ...},
        overlayTwo: {... overlay properties ...},
        ...
        overlayM: {... overlay properties ...}    }
}
            

An overlay layer can be any type of layer, so a base layer can be an overlay. Other common overlays can be layer groups, for example, when a certain groups of markers are grouped.

For overlays that are baselayers (XYZ, WMS, etc) the baselayers rules for the model apply, for other types (Group, Features, Clusters, etc), the following rules apply:

  • name: The display name in the layer control
  • type: The type of layer. The accepted values are: 'group' and 'cluster'
It can also contain optional properties (for all overlays of type XYZ or WMS)
  • visible: The overlay will be initially displayed on the map

Note:

The code below is the definition of overlays in this example.

Layer hillshade is a wms layer. Layer OpenFireMap is a xyz layer.

overlays: {
    hillshade: {
        name: 'Hillshade Europa',
        type: 'wms',
        url: 'http://129.206.228.72/cached/hillshade',
        visible: true,
        layerOptions: {
            layers: 'europe_wms:hs_srtm_europa',
            format: 'image/png',
            opacity: 0.25,
            attribution: 'Hillshade layer by GIScience http://www.osm-wms.de',
            crs: L.CRS.EPSG900913
        }
    },
    fire: {
        name: 'OpenFireMap',
        type: 'xyz',
        url: 'http://openfiremap.org/hytiles/{z}/{x}/{y}.png',
        layerOptions: {
            attribution: '© OpenFireMap contributors - © OpenStreetMap contributors',
            continuousWorld: true
        }
    }
}
            

This is a map with dynamic addition and deletion of Overlays