flutter-mapbox-gl / maps

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

Clusters on iOS #1319

Closed Diielle closed 1 year ago

Diielle commented 1 year ago

Hi,

I am trying to insert clusters into my map. I have used this code:

var allPoints = {
      "type": "FeatureCollection",
      "crs": {
        "type": "name",
        "properties": {"name": "urn:ogc:def:crs:OGC:1.3:CRS84"}
      },
      "features": allSymbolGEOJSON,
    };
    var source = await mapController.addSource(
      "earthquakes",
      GeojsonSourceProperties(
        data: allPoints,
        cluster: true,
        clusterMaxZoom: 14,
        clusterRadius: 50,
      ),
    );
    await mapController.addLayer(
      "earthquakes",
      "clusters",
      const CircleLayerProperties(circleColor: [
        Expressions.step,
        [Expressions.get, 'point_count'],
        '#51bbd6',
        5,
        '#f1f075',
        10,
        '#f28cb1',
        20,
        '#008000'
      ], circleRadius: [
        Expressions.step,
        [Expressions.get, 'point_count'],
        20,
        100,
        30,
        750,
        40
      ], circleOpacity: [
        "case",
        ["has", "point_count"],
        1.0,
        [
          "!",
          ["has", "point_count"]
        ],
        0.0,
        1.0
      ]),
    );
    await mapController.addLayer(
        "earthquakes",
        "cluster-count",
        const SymbolLayerProperties(
          textField: [Expressions.get, 'point_count_abbreviated'],
          textSize: 12,
        ));

    await mapController.addSymbolLayer(
      "earthquakes",
      "unclustered-point",
      const SymbolLayerProperties(
        textField: [Expressions.get, "name"],
        textHaloWidth: 1,
        textSize: 12.5,
        textHaloColor: '#ffffff',
        textOffset: [
          Expressions.literal,
          [0, 2]
        ],
        iconImage: [Expressions.get, 'icona'],
        iconSize: 0.15,
        iconAllowOverlap: true,
        textAllowOverlap: true,
        textColor: '#000000',
        textHaloBlur: 1,
      ),
      filter: [
        '!',
        ['has', 'point_count']
      ],
      enableInteraction: true,
    );

It works on android but not on iOS. Do you have any idea what I'm doing wrong?

Thank you.