Hillshade Style Layer
The HillshadeStyleLayer is either used by the map style or can be added to the map
programmatically to use DEM tiles. Those tiles are used to render elevation on
the map.
Basic Usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 late final MapController _controller ;
@override
Widget build ( BuildContext context ) {
return MapLibreMap (
options: MapOptions ( center: Geographic ( lon: 9.17 , lat: 47.68 )),
onMapCreated: ( controller ) => _controller = controller ,
onStyleLoaded: ( style ) async {
const hillshade = RasterDemSource (
id: _sourceId ,
url: 'https://demotiles.maplibre.org/terrain-tiles/tiles.json' ,
tileSize: 256 ,
);
await style . addSource ( hillshade );
const layer = HillshadeStyleLayer (
id: _layerId ,
sourceId: _sourceId ,
paint: { 'hillshade-shadow-color' : '#473B24' },
);
await style . addLayer ( layer );
}
);
}
Check out
the example app
to learn more.
Style & Layout
Use the paint property to change the style and the layout
property to change the behavior on the map.
Read the Paint & Layout chapter to learn more on this
topic.