mapbox / mapbox-maps-flutter

Interactive, thoroughly customizable maps for Flutter powered by Mapbox Maps SDK
https://www.mapbox.com/mobile-maps-sdk
Other
252 stars 93 forks source link

PointAnnotation disappear on update [Example app] #339

Open sikandernoori opened 5 months ago

sikandernoori commented 5 months ago

In example app point_annotation page.

When I try and update PointAnnotation as per below code in example app then PointAnnotation disappears.

class AnnotationClickListener extends OnPointAnnotationClickListener {
  AnnotationClickListener(this.pointAnnotationManager);

  final PointAnnotationManager pointAnnotationManager;
  @override
  void onPointAnnotationClick(PointAnnotation annotation) async {
    print("onAnnotationClick, id: ${annotation.id}");
    if (annotation.textField == null) {
      annotation.textField = "Test data";
      annotation.textOffset = [0.0, -2.0];
      annotation.textColor = Colors.red.value;
      annotation.iconSize = 1.3;
      annotation.iconOffset = [0.0, -5.0];
    } else {
      annotation.textField = null;
    }
    await pointAnnotationManager.update(annotation);
  }
}

What i am trying to do here is if no text is being displayed then show text, if text is displayed then hide text.

Text show and hide works fine, but it also hide marker icon.

sikandernoori commented 5 months ago

Demo:

https://github.com/mapbox/mapbox-maps-flutter/assets/16399272/609f62c0-53d4-4dd4-9406-7cd1ee3ec110

oppware commented 4 months ago

I have the same issue for flutter -> iOS! A simple update() of the annotation makes them disappear. Works fine for android but not iOS. How can something as simple as that be broken? Isn't it basic functionality? I need an urgent fix otherwise I have to revert my project back to google maps.

oppware commented 4 months ago

I have found a workaround! pointAnnotation.iconImage is set to a random string which looks like some sort of uuid and regarding to the doc /// The bitmap image for this Annotation /// Will not take effect if [iconImage] has been set. Uint8List? image; the image is ignored and therefor the annotation disappears. I now set iconImage = null before I do the update() on the annotation! Works for me.

fegabe commented 3 months ago

I'm also experiencing the same problem on iOS. After calling update the marker disappears. I tried the workaround but it's not working for me.

oppware commented 3 months ago

I'm also experiencing the same problem on iOS. After calling update the marker disappears. I tried the workaround but it's not working for me.

Could you get around the problem?

oppware commented 3 months ago

reading the latets update notes for v1.0.0... Fix point annotation image disappearing after update on iOS. This problem should be fixed. haven't tried it yet though.