Annotation layers show your own points, lines and areas on the map. Put them
in the MapLibreMap.layers list and change them like any other widget
parameter, with setState() or the state management of your choice. The map
adds, updates and removes only what changed.
bool_imageLoaded=false;final_points=<Feature<Point>>[constFeature(geometry:Point(Geographic(lon:9.17,lat:47.68))),constFeature(geometry:Point(Geographic(lon:9,lat:48))),];@overrideWidgetbuild(BuildContextcontext){returnMapLibreMap(options:MapOptions(initCamera:.position(center:Geographic(lon:9.17,lat:47.68),zoom:7)),onStyleLoaded:(style)async{awaitstyle.addImageFromIconData(id:'marker',iconData:Icons.location_on,color:Colors.red,);setState(()=>_imageLoaded=true);},// add a marker where the user tapsonClick:(event)=>setState(()=>_points.add(Feature(geometry:Point(event.point)))),layers:[MarkerLayer(points:_points,textField:const.literal('Marker'),textAllowOverlap:const.literal(true),iconImage:_imageLoaded?const.literal('marker'):null,iconAnchor:const.literal(IconAnchor.bottom),textOffset:const.literal(Offset(0,1)),),],);}
A map can show any number of annotation layers, each with its own style. For
properties that the annotation layers don't have, use the
style layer they are built on.