mapbox / mapbox/mapbox-maps-flutter

Annotation doesn't appear when creating point for the first time

Open
#296 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Dart
Stars
380
Forks
204
PR merge metrics
No merged PRs in 30d

Description

Hey everyone, I'm having a problem with adding an image using the point annotation manager. when I run this code for the first time the pin doesn't appear. I don't get any error and the code runs all every time

```
Future addPin(Node node, bool isAsset) async {
if (_isDisposed) return;
try {

final image = await MapUtils.createImageFromWidget(
PinWidget(
repaintKey: _repaintKey, width: 60, height: 71, isAsset: isAsset),
);
if (pinManager != null){
await _controller.annotations.removeAnnotationManager(pinManager!);
}
pinIsAsset = isAsset;
pinUuid = node.uuid;

pinManager = await _controller.annotations.createPointAnnotationManager();
if(image == null) print("image is null");
final pin = await pinManager!.create(PointAnnotationOptions(
geometry: node.gpsData.toPointMap,
image: image,
iconOffset: [-math.pi / 2, 5],
iconAnchor: IconAnchor.BOTTOM));


} catch (e, s) {
print('error: ' + e.toString());
print('stack:' + s.toString());
return;
}
}
```

I delete and create the manager each time to keep the point after all the layers.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the first call to addPin and follow the creation of the point annotation manager through pinManager!.create. Compare the first run with later runs, including the manager removal and image creation steps. Done means the pin appears on the first call without errors and remains after the layer operations.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.