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

How to make the overlapping background obscure the text? #760

Open
M2dL1fe opened this issue Nov 5, 2024 · 7 comments
Open

How to make the overlapping background obscure the text? #760

M2dL1fe opened this issue Nov 5, 2024 · 7 comments

Comments

@M2dL1fe
Copy link

M2dL1fe commented Nov 5, 2024

image

@evil159
Copy link
Contributor

evil159 commented Nov 11, 2024

@M2dL1fe
Copy link
Author

M2dL1fe commented Nov 12, 2024

I don't need Collision detection.
I want the background to block the text,In order of precedence. @evil159

@evil159
Copy link
Contributor

evil159 commented Nov 12, 2024

@M2dL1fe, I see, could you provide a code snippet showcasing how you setup price markers to be shown?

@M2dL1fe
Copy link
Author

M2dL1fe commented Nov 13, 2024

List<MapEntry<Point, String>> list = [
    MapEntry(Point(coordinates: Position(175.06285, -40.879502000000002)), "\$1.01M"),
    MapEntry(Point(coordinates: Position(175.06292500000001, -40.878473)), "\$828K"),
    MapEntry(Point(coordinates: Position(175.063095, -40.878227000000003)), "\$745K"),
    MapEntry(Point(coordinates: Position(175.06317200000001, -40.879559)), "\$670K"),
    MapEntry(Point(coordinates: Position(175.06311857994999, -40.879370662215003)), "\$613K"),
    MapEntry(Point(coordinates: Position(175.06311857994999, -40.879370662215003)), "\$563K"),
    MapEntry(Point(coordinates: Position(175.063425, -40.878906000000001)), "\$590K"),
  ];

  addImage(MapboxMap controller) async {
    final bytes = await rootBundle.load('images/iconImage.png');
    await controller.style.addStyleImage("iconImage", 2, MbxImage(data: bytes.buffer.asUint8List(), width: 130, height: 59), false, [ImageStretches(first: 30, second: 40), ImageStretches(first: 90, second: 100)], [ImageStretches(first: 23, second: 28)], ImageContent(left: 15, right: 115, top: 5, bottom: 45));
  }

  addPointAnnotations(MapboxMap controller) async {
    final pointAnnotationManager = await controller.annotations.createPointAnnotationManager();
    pointAnnotationManager.setTextIgnorePlacement(true);
    pointAnnotationManager.setTextAllowOverlap(true);
    pointAnnotationManager.setIconAllowOverlap(true);
    pointAnnotationManager.createMulti(createAnnotations());
  }

  List<PointAnnotationOptions> createAnnotations() => list
      .map((it) => PointAnnotationOptions(
            geometry: it.key,
            textField: it.value,
            iconImage: "iconImage",
            symbolSortKey: 1,
            textJustify: TextJustify.CENTER,
            textAnchor: TextAnchor.CENTER,
            iconTextFit: IconTextFit.BOTH,
            textColor: Colors.white.value,
            textSize: 12,
          ))
      .toList();

iconImage

@evil159

@M2dL1fe
Copy link
Author

M2dL1fe commented Nov 13, 2024

    pointAnnotationManager.setTextIgnorePlacement(true);
      pointAnnotationManager.setTextAllowOverlap(true);
      pointAnnotationManager.setIconAllowOverlap(true);
      pointAnnotationManager.setTextOptional(true);

The same is true with the above Settings

@evil159
Copy link
Contributor

evil159 commented Nov 13, 2024

@M2dL1fe Thank you for the sample code, specify symbolSortKey to prevent symbols from overlapping, e.g. in your sample

  List<PointAnnotationOptions> createAnnotations() => list
      .map((it) => PointAnnotationOptions(
            geometry: it.key,
            textField: it.value,
            iconImage: "iconImage",
            symbolSortKey: 1,
            textJustify: TextJustify.CENTER,
            textAnchor: TextAnchor.CENTER,
            iconTextFit: IconTextFit.BOTH,
            textColor: Colors.white.value,
            textSize: 12,
-          )
+          )..symbolSortKey = list.indexOf(it).toDouble()
          
          )
      .toList();

@M2dL1fe
Copy link
Author

M2dL1fe commented Nov 14, 2024

How do we do this when symbolSortKey is consistent? @evil159

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