mapbox-maps-flutter icon indicating copy to clipboard operation
mapbox-maps-flutter copied to clipboard

PointAnnotation disappear on update [Example app]

Open sikandernoori opened this issue 2 years ago • 6 comments

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 avatar Jan 02 '24 13:01 sikandernoori

Demo:

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

sikandernoori avatar Jan 02 '24 13:01 sikandernoori

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 avatar Feb 02 '24 19:02 oppware

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.

oppware avatar Feb 02 '24 20:02 oppware

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.

fernandogcat avatar Feb 16 '24 11:02 fernandogcat

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 avatar Feb 27 '24 22:02 oppware

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.

oppware avatar Mar 03 '24 01:03 oppware