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

Using text-translate in symbol paint doesn't update collision boxes #210

Closed
timsluis opened this issue Jul 14, 2021 · 14 comments · Fixed by #4071
Closed

Using text-translate in symbol paint doesn't update collision boxes #210

timsluis opened this issue Jul 14, 2021 · 14 comments · Fixed by #4071
Labels

Comments

@timsluis
Copy link

When adding a text-translate property to a layer the collision boxes won't move together with the labels. Also click and hovers are registered on the original place of the label before the translate.

Screenshot 2021-07-14 at 11 03 00

maplibre-gl-js version: 1.15.2

browser: Chrome 91

Steps to Trigger Behavior

  1. Add a symbol layer
  2. Provide a text-translate on the paint property of a layer

Link to Demonstration

See: https://codepen.io/timsluis/pen/qBmRYQM

Expected Behavior

Collision boxes are updated.

Actual Behavior

Collision boxes are not updated and labels flow over each other.

@github-actions
Copy link
Contributor

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Oct 14, 2021
@xabbu42
Copy link
Contributor

xabbu42 commented Oct 18, 2021

This bug still exists and the issue should stay open.

@github-actions github-actions bot removed the Stale label Oct 19, 2021
@github-actions
Copy link
Contributor

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Apr 18, 2022
@github-actions
Copy link
Contributor

This issue was closed because it has been stalled for 30 days with no activity.

@wipfli
Copy link
Member

wipfli commented May 19, 2022

Wasn't there something related in the terrain3d pull request? @timsluis would you be interested in fixing this?

@mrflix
Copy link

mrflix commented Dec 21, 2023

The bug is still very much there: I'm using both text-translate and icon-translate to offset symbols so that the pin points to the exact location. I would like to use icon-offset and text-offset instead, but I can't because I use text-variable-anchor and text-radial-offset for dynamic label placement and that overwrites text-offset.

This is the result of using text-translate and icon-translate:
Screenshot 2023-12-21 at 13 47 58
Outlined in 🟦 is the original position, 🟥 the translated position. The mouseover and click area is 🟦.
So only the bottom right of the visual area can be clicked 😟

@HarelM
Copy link
Member

HarelM commented Dec 24, 2023

Reopening.
I think it's somewhat related to:

The collision box logic is not great in general...

@HarelM HarelM reopened this Dec 24, 2023
@kubapelc
Copy link
Contributor

I think I might have fixed this, see #3456

@mrflix
Copy link

mrflix commented Mar 12, 2024

@kubapelc thanks for looking into this and sharing your work. I tested it with http://kvaleya.gitlab.io/maplibre/aligndemo2/maplibre-gl-dev.js. Unfortunately the labels all move into the top left corner of the canvas:

Screenshot 2024-03-12 at 11 20 24

These are my layout and paint settings: (I removed some text formatting and styling that I think doesn't influence the position – e.g. text-size, text-font, text-field, text-opacity)

{
  layout: {
    'text-variable-anchor': ['left', 'right', 'bottom', 'top'],
    'text-radial-offset': 1.25,
    'text-optional': true,
    'text-overlap': 'cooperative'
  },
  paint: {
    'text-translate': ["interpolate", ["linear", 1],
      ["zoom"], 8, ["literal", [-2, -1.7]], 17, ["literal", [-20, -17]],
    ],
  }
}

@kubapelc
Copy link
Contributor

@mrflix thank you for the layout settings, I'll use them for testing. It seems that variable anchors don't work at all in my branch. I'll try to fix it. Symbols without variable anchors should work though.

@kubapelc
Copy link
Contributor

kubapelc commented Apr 5, 2024

@mrflix Hi, is the bug still present if you use the maplibre build from https://kvaleya.gitlab.io/maplibre/aligndemo3/combineddemo.html ? I had a bug in text-variable-anchor handling that was causing the symbols to be placed in the top left corner, it should now be fixed.

@mrflix
Copy link

mrflix commented Apr 8, 2024

@kubapelc the click areas seem to be correct now but the text is placed incorrectly:
Screenshot 2024-04-08 at 16 55 06
How it should be placed: (live version)
Screenshot 2024-04-08 at 16 52 32

@kubapelc
Copy link
Contributor

kubapelc commented Apr 9, 2024

@mrflix I fixed another bug with text-variable-anchor + text-translate interaction: maplibre build. This should fix the wrong placement. But I think text-variable-anchor + text-translate + text-pitch-alignment: 'map' will still behave in weird ways, but that doesn't seem to be used in your map.

@kubapelc
Copy link
Contributor

kubapelc commented May 2, 2024

I've (hopefully) finished adapting symbols for globe, see the PR mention, and now I'm fairly confident that most reasonable combinations of text, icon, text/icon-translate, text/icon-translate-anchor, text-variable-anchor, text-pitch-alignment, text-rotation-alignment should work, along with proper collisions and click areas (but I can't rule out some broken edgecases remaining). The PR includes bugfixes for symbols even for the regular mercator projection. If you want to try it out, see here:

Globe demo

MapLibre build used in globe demo (different build than what is linked in the previous comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants