Skip to main content

<layer->

Maps have one or more layers. Map layers are implemented by the <layer-> custom element.
All <mapml-viewer> content is contained by one or more <layer-> elements, either inline or by remote fetch representing the layer's content.

<layer- label="My Layer" checked>
...layer content goes here...
</layer->

<layer-> is not a 'void' element - it must be closed with a </layer-> tag.

Map content can either be inline, as shown above - between the beginning <layer-> and ending </layer-> tags - or fetched, from the <layer- src="..."></layer-> source attribute URL:

<layer- label="My Layer" src="https://example.org/mapml/mylayer" checked></layer->

This documentation uses the convention of inline content mostly. Fetched map content follows similar semantics, except it is parsed with the browser's XML parser and so must follow both MapML document conventions as well as XML syntax rules.

Attributes

src

Contains the path to a MapML document.


checked

The <layer- checked> attribute and property is boolean. When present, the checked property value is taken to be 'true'; when not present, the property value is 'false'. Beware that it is the presence of the attribute that makes it true, not the value of the attribute. For example, the attribute checked="false" actually turns out to be checked, as described by MDN Web docs.


hidden

The <layer- hidden> attribute and property is boolean. When present, the layer is hidden in the layer control.


label

The label attribute is used by inline content as the displayed text label of the layer in the layer control. In fetched content, the label attribute is ignored, and the fetched <map-title> element is used.


opacity

The opacity attribute is used to set the initial opacity of the <layer-> element. Valid opacity values range from from "0.0" to "1.0" and are reflected in the layer control opacity input slider control. When the opacity attribute is not present, the opacity is set to "1.0" by default.


Examples

Layer Opacity

The following example sets the initial opacity for a <layer->.

<mapml-viewer projection="CBMTILE" zoom="2" lat="45" lon="-90" controls>
<layer- opacity = "0.5" label="CBMT" src="https://geogratis.gc.ca/mapml/en/cbmtile/cbmt/" checked></layer->
</mapml-viewer>

Specifications

Specification
MapML layer element

Requirements

Report problems with these requirements on GitHub

requirementenhancementimpracticalundecidedunder discussion

SpecViewerAPI
Rendering base layers (5.1)
Display an image file as a map layer (5.1.3)
under reviewlimited
User navigation (pan and zoom) (5.4)
Maintain reasonable scale of labels and lines when zooming (5.4.5)
limitedfull