addLayer abstract method

Future<void> addLayer(
  1. StyleLayer layer, {
  2. String? belowLayerId,
  3. String? aboveLayerId,
  4. int? atIndex,
})

Add a new layer to the map. The source must be added before adding it to the map.

belowLayerId The ID of an existing layer to insert the new layer before, resulting in the new layer appearing visually beneath the existing layer.

aboveLayerId The ID of an existing layer to insert the new layer after, resulting in the new layer appearing visually above the existing layer. This parameter will be ignored on web.

atIndex is the position at which to insert the layer. An index of 0 would send the layer to the back; an index equal to the number of objects in the layers property would bring the layer to the front. This parameter will be ignored on web.

If more than one positioning parameter is specified, it will first try to use belowLayerId, then aboveLayerId and finally atIndex. If no positioning parameter is specified, the layer will be appended to the end of the layers array and appear visually above all other layers.

Implementation

Future<void> addLayer(
  StyleLayer layer, {
  String? belowLayerId,
  String? aboveLayerId,
  int? atIndex,
});