Skip to content

Can not add image to the Snaphotter #537

Open
@bf-apcoa

Description

@bf-apcoa

This code works with MapBox controller object but when Snapshotter is used, marker is not drawn on the map.

  Future<void> _addMarker() async {
    final bytes = await rootBundle.load(Assets.image.mapPin.keyName);
    final list = bytes.buffer.asUint8List();
    await _snapshotter?.style.addStyleImage(
      'icon',
      1,
      MbxImage(width: 10, height: 10, data: list),
      true,
      [],
      [],
      null,
    );

    final geometry = {
      'type': 'Point',
      'coordinates': [
        widget.coordinates.longitude,
        widget.coordinates.latitude,
      ],
    };
    final data = {'type': 'Feature', 'geometry': geometry};
    final source = {'type': 'geojson', 'data': data};
    await _snapshotter?.style
        .addStyleSource('point_source', json.encode(source));

    final symbolLayer = SymbolLayer(
      id: 'point',
      sourceId: 'point_source',
      symbolPlacement: SymbolPlacement.POINT,
      iconAllowOverlap: true,
      iconAnchor: IconAnchor.BOTTOM_LEFT,
      iconImage: 'icon',
      iconColor: Colors.amber.value,
      iconSize: 1,
    );
    await _snapshotter?.style.addLayer(symbolLayer);
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions