Layer
To display objects on the map after it is created, add layers.
A layer is a visual component responsible for rendering objects on the map. For example, the marker layer displays points on the map, and the tile layer displays the geographic map itself.
Layers can be metaphorically described as a puff pastry. Each instance of the MMapLayer class can be displayed above or below another instance of the same class.
Maps can contain any number of layers, the API does not limit you. For example, you may add a layer that displays images with clouds, place a tile layer under it, and add a traffic layer in between.
Alert
By default, the map displays layers in the order in which they were added.
You can manage the layer order using the zIndex
parameter.
You can set the order in which the layers are displayed by the order in which you add the layers to the map or using the zIndex
parameter (by default, the value specified in MMapLayer.defaultProps.zIndex is used).
Alert
Each layer displays data from a specific data source, so be sure to add sources to the map before adding layers.
Examples:
map.addChild(
new MMapLayer({
source: 'urlSource',
type: 'tiles'
})
);
map.addChild(
new MMapLayer({
source: 'tileGeneratorSource',
type: 'tiles',
zIndex: 2000,
raster: {
// Use this option to wait until all visible tiles load before displaying them.
awaitAllTilesOnFirstDisplay: true,
// This option sets the duration of the loaded tiles' display animation
tileRevealDuration: 0
}
})
);
map.addChild(
new MMapLayer({
source: 'markerSource',
type: 'markers',
zIndex: 2020
})
);
map.addChild(
new MMapLayer({
source: 'featureSource',
type: 'features',
zIndex: 2010
})
);
The layers will be displayed as follows:
urlSource
tileGeneratorSource
featureSource
markerSource
For convenient usage, the following default layers are provided:
- MMapDefaultSchemeLayer combines a tile data source and a set of layers to display the Mappable road map.
- MMapDefaultFeaturesLayer combines a data source for geo objects and a layer for displaying it.