Layers & Sources
Style layers render data from a source with full control over how it looks, and they scale to datasets the annotation API cannot. Start with the source, then pick the layer that matches your geometry: symbol and circle for points, line for paths, fill for areas, heatmap and cluster for many points at once.
- Symbol Layer: icons and text labels from a source
- Circle Layer: circular points
- Fill Layer: polygons and filled areas
- Line Layer: polylines and paths
- Heatmap: point density as a heat surface
- Color Relief: terrain coloured by elevation from a raster DEM
- Background: a colour or pattern behind every other layer
- Cluster: cluster many points into grouped circles
- GeoJSON Source: feed layers from inline data or a URL
- Various Sources: GeoJSON, vector tiles, raster tiles, and more
Manage layers
Once a layer is on the map, these calls change it without removing and adding it again:
// Draw 'labels' below 'roads'; without belowLayerId it goes on top.
await controller.moveLayer('labels', belowLayerId: 'roads');
// Draw 'buildings' only from zoom 14 up.
await controller.setLayerZoomRange('buildings', 14, 24);
// Hide a group of layers in one call, all in the same frame.
final missing = await controller.setLayersVisibility(['roads', 'labels'], false);
moveLayerkeeps the layer's properties, filter and source.setLayerZoomRangetakes zooms from 0 to 24:minzoomis inclusive,maxzoomexclusive.setLayersVisibilityskips the ids the style does not have, and returns them.
When a call fails
Layer and source calls throw a PlatformException with the same code on every platform, and a failed call changes nothing. The message names the property, layer or source at fault, and Errors lists every code.