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

3.9.0 Beta - Icon Anchor offset inconsistent #13354

Open
david-buck opened this issue Dec 17, 2024 · 3 comments
Open

3.9.0 Beta - Icon Anchor offset inconsistent #13354

david-buck opened this issue Dec 17, 2024 · 3 comments
Labels

Comments

@david-buck
Copy link

mapbox-gl-js version:
3.9.0 beta

browser:
Chrome 131

Steps to Trigger Behavior

I have a sprite that was created with a built-in offset to make it easier to overlay on another icon on a map
the sprite looks like this in mapbox

image

but actually is framed like this

image

on my map using < 3.9.0 (currently 3.8.0) the overlaid icons render like this

image

but in 3.9.0, the icon-anchor seems to be offsetting and appears like this
image

the pertinent part of my code being

    mapInstance.addLayer({
      id: "pointer-layer",
      type: "symbol",
      source: "vehicles",
      layout: {
        "icon-image": "vehicle-arrow",
        "icon-rotate": [
          "get", "bearing"
        ],
        "icon-size": [
          "interpolate",
          ["linear"],
          ["zoom"],
          10,
          0.4,
          16,
          0.85,
          22,
          1.6,
        ],
        "icon-allow-overlap": true,
        "icon-anchor": "bottom",
        "icon-rotation-alignment": "map",
      },
    });

Expected Behavior

Unsure if the 3.8.0 behaviour is as intended and 3.9.0 is broken or vice-versa but this is a change.

@david-buck
Copy link
Author

This difference is still present in 3.9.0 (non-beta) but not mentioned in the release notes.

@underoot
Copy link
Member

Hey, @david-buck! Thank you for your report. Currently, we have inconsistency between client rasterization of vector icons and how we rasterize them in our sprites API. To quickly solve the problem with your style, you can do one of the following:

  • Change icon-anchor to center to reflect the change in the client-side rendering behavior (your arrow position will be the same as you have in your original SVG)
  • Move back to raster icons by passing spriteFormat: 'raster'

@david-buck
Copy link
Author

Thanks, @underoot for the advice.

When I changed the anchor to center, it rendered in a third, new way. I've just updated my zoom and anchor rules to accommodate the difference and can update again later.

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

No branches or pull requests

2 participants