flutter-maplibre-gl icon indicating copy to clipboard operation
flutter-maplibre-gl copied to clipboard

Adding Symbols and circles on top of fill layers not working

Open scarranca opened this issue 2 years ago • 1 comments

Hi, I'm trying to create a circle and symbols on top of fill layers, but they are always below the layers. I've tried to this annotationOrder: const <AnnotationType>[ AnnotationType.fill, AnnotationType.line, AnnotationType.symbol, AnnotationType.circle, ],

    But it's not working, the circles still showing behind the layers.
    
    

scarranca avatar Sep 08 '22 00:09 scarranca

I confirm, the AnnotationManager layers are added before we can add the layers like we can see in annotation_manager.dart:39.

The only workaround for now is to replace the layers at the top everytime you add a layer without the placeBelow argument like here :

List<String>? layerIds = controller.circleManager?.layerIds;
List<LayerProperties>? layerProps = controller.circleManager?.allLayerProperties;
if (layerIds == null || layerProps == null) {
  return;
}
for (int i = 0; i < layerIds.length; i++) {
  String id = layerIds[i];
  await controller.removeLayer(id);
  await controller.addLayer(id, id, layerProps[i]);
}

We really need a modification of the way annotations are created.

EDIT: typos

EDIT 2: A function named _rebuildLayers is present in the annotation controller. It basically do what i described on this post but it is marked as private.

Future<void> _rebuildLayers() async {
  for (var i = 0; i < allLayerProperties.length; i++) {
    final layerId = _makeLayerId(i);
    await controller.removeLayer(layerId);
    await controller.addLayer(layerId, layerId, allLayerProperties[i]);
  }
}

you can duplicate it to your project and execute it for all annotation types everytime a layer is added at the top of your layer stack.

mariusvn avatar Oct 26 '22 13:10 mariusvn