maplibre / flutter-maplibre-gl

Customizable, performant and vendor-free vector and raster maps, flutter wrapper for maplibre-native and maplibre-gl-js (fork of flutter-mapbox-gl/maps)
https://pub.dev/packages/maplibre_gl
Other
185 stars 106 forks source link

[BUG] Data property in annotations not added to properties #462

Open XanderD99 opened 2 weeks ago

XanderD99 commented 2 weeks ago

Platforms

all

Version of flutter maplibre_gl

latest

Bug Description

The data property that can be passed to the annotations is not added to the properties in geojson.

I know it can be done by setting the annotationColor properties from the specific annotation options but that would create such a messy function with a lot of nested if elses or switch cases that I rather just add in custom properties with a customised layer so that the map styles handle it

Other then that I think it will also benefit that the general onFeatureTapped also gets all the data properties that are in that feature.

Steps to Reproduce

  1. Create custom annotation layer style with data driven element
  2. Create annotation with data property set to anything
  3. add annotation to map

Expected Results

Data properties to be added to the geojson properties so that they can be used in layer styles.

Actual Results

data is not used or passed to the togeojson

Code Sample

class EventLayerManager extends AnnotationManager {
  EventLayerManager(super.controller) : super(enableInteraction: false);

  void addEvent(final LatLng geometry, final String type) async {
    final options = CircleOptions(geometry: geometry);

    final circle = Circle('some_id', options, {'type': type});

    await add(circle);
  }

  @override
  List<LayerProperties> get allLayerProperties => [
        CircleLayerProperties(
          circleRadius: 2,
          circleColor: [
            'match',
            ['get', 'type'],
            'accident', 'red',
            'blue',
          ],
        ),
      ];
}