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

Point annotations disapear when zooming out #586

Open
Mowglli opened this issue Jun 15, 2024 · 2 comments
Open

Point annotations disapear when zooming out #586

Mowglli opened this issue Jun 15, 2024 · 2 comments

Comments

@Mowglli
Copy link

Mowglli commented Jun 15, 2024

Hello,
When i zoom out my pointannotaions dissapear, when i zoom in again they show up once again. Im currently testing on IOS.
Do i do something wrong here?

The following code, is what i use for making the points at the moment:

_onMapCreated(MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.annotations.createPointAnnotationManager().then((value) async {
pointAnnotationManager = value;
final ByteData bytes =
await rootBundle.load('assets/images/onboarding0.png');
final Uint8List list = bytes.buffer.asUint8List();

      pointAnnotationManager?.setIconAllowOverlap(true);
      pointAnnotationManager?.setIconIgnorePlacement(true);
      createEventAnnotations();

      pointAnnotationManager?.addOnPointAnnotationClickListener(
          AnnotationClickListener(context, events, mapboxMap));
    });
  }
 List<Event> events = [
    Event(
      id: '1',
      holderName: 'Pizza Boys',
      address: 'husene, 2',
      title: 'Spis min gris',
      tags: 'food',
      description: 'Lækker skinke!',
      imageUrls: ['http://example.com/image1.jpg'],
      latitude: 56.1685,
      longitude: 10.2134,
    ),]
void createEventAnnotations() async {
    final ByteData bytes =
        await rootBundle.load('assets/images/onboarding0.png');
    final Uint8List list = bytes.buffer.asUint8List();

    List<PointAnnotationOptions> annotationOptions = events.map((event) {
      return PointAnnotationOptions(
        geometry: Point(
            coordinates:
                TurfPosition.Position(event.longitude, event.latitude)),
        textField: event.title,
        textOffset: [0.0, -4.0],
        textColor: Colors.red.value,
        iconSize: 0.3,
        iconOffset: [0.0, -5.0],
        symbolSortKey: 10.0,
        image: list,
      );
    }).toList();

    pointAnnotationManager?.createMulti(annotationOptions);
  }
testi.mov
@evil159
Copy link
Contributor

evil159 commented Jun 27, 2024

Hi @Mowglli, you can read about symbol placement optimization here: Mapbox - Optimize map label placement.

@Mowglli
Copy link
Author

Mowglli commented Jun 27, 2024

@evil159 - Thank you, i'll have a read. It works as intended on Android.

@Mowglli Mowglli closed this as completed Jun 27, 2024
@Mowglli Mowglli reopened this Jun 27, 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

2 participants