flutter-mapbox-gl / maps

A Mapbox GL flutter package for creating custom maps
Other
1.04k stars 503 forks source link

Cluster properties is not created #1372

Closed amitchandra-logiciel closed 11 months ago

amitchandra-logiciel commented 1 year ago

Hi, I want to highlight cluster when any selected is true in cluster group. but seem like cluster properties not created.

Future<void> addSource(data) async {
    for (var feature in data?['features'] ?? []) {
      feature['properties']['amount_label'] = Helper.getCurreny(
        feature['properties']['max_price'], 
        useCompact: true,
      );
      feature['properties']['selected'] = true;
    }
    propertiesInMap = data;

    if (propertiesInMap?.containsKey('features') ?? false) {
      await mapController?.addSource(
        'properties', 
        GeojsonSourceProperties(
          cluster: true,
          data: propertiesInMap,
          clusterProperties: {
            'has_selected': [
              Expressions.any, 
              [Expressions.equal, [Expressions.get, "selected"], true],
            ],
            // 'has_selected': [Expressions.has, 'point_count']
          },
        ),
      ); 

      await addLayer();
    }
  }
  Future<void> addLayer() async {
    await mapController?.addCircleLayer(
      'properties', 
      'cluster-point',
      const CircleLayerProperties(
        circleRadius: 12,
        circleColor: [
          Expressions.caseExpression,
          [Expressions.equal, [Expressions.get, 'has_selected'], true],
          "#006AF9",
          "#DC00FE",
        ],
      ),
      filter: [Expressions.has, 'point_count'],
    );
}
stale[bot] commented 11 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.