Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not add image to the Snaphotter #537

Open
bf-vs opened this issue May 8, 2024 · 0 comments
Open

Can not add image to the Snaphotter #537

bf-vs opened this issue May 8, 2024 · 0 comments

Comments

@bf-vs
Copy link

bf-vs commented May 8, 2024

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);
  }
@bf-vs bf-vs changed the title Can not add image to the snapshot Can not add image to the Snaphotter May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant