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

CollisionTile minScale/maxScale range is too small for overzoomed tiles, causing labels to disappear #5072

Closed
flypdx opened this issue Aug 1, 2017 · 8 comments
Assignees
Labels

Comments

@flypdx
Copy link

flypdx commented Aug 1, 2017

label_issue

Migrating from v0.35.1 to v0.39.1 I noticed that my symbol features show erratic behavior (symbols disappear or become severed) when you zoom into a grouping of symbols, set pitch, and start rotating. See GIF above. I do not have this issue in v0.35.1 (please see version details below for more info).

mapbox-gl-js version: 0.39.1

Testing back versions I noticed the same issue with v0.39.0 and v0.38.0.

The issue is not seen in v0.37.0 and earlier releases.

Steps to Trigger Behavior

  1. Add a symbol type layer via URL to your map with a text-field….
          map.addLayer({
                "id": "layer-id-here",
                "type": "symbol",
                "source": {
                    'type': 'geojson',
                    'data': 'data URL here’

                },
                "layout": {
                    "text-field": "{text-field-here}",
                    "icon-allow-overlap": true,
                    "text-allow-overlap": true
                },
                "paint": {
                    "text-color": 'red',
                    "text-halo-color": 'white',
                    "text-halo-width": 1.5,

                },
            });
  1. Zoom to a dense grouping of text from the symbol feature and activate pitch and start rotating.

Expected Behavior
Symbol text should not disappear from the map when map is at a pitch and rotated.

Actual Behavior
See GIF above. Symbol text disappears when the view is at a pitch and the map is rotated.

@jfirebaugh
Copy link
Contributor

Thanks for using Mapbox, and sorry to hear you're running into an issue. In order for us to diagnose this issue, we'll need to be able to reproduce it ourselves. Could you please create a minimal self-contained JSFiddle that demonstrates the issue?

@flypdx
Copy link
Author

flypdx commented Aug 1, 2017 via email

@ChrisLoer
Copy link
Contributor

Hi @flypdx, I tried running the JSFiddle you posted (thanks!) but didn't see any behavior like the bulk disappearing labels you recorded in that original GIF. We did make changes in v0.38 that changed how text was rendered in pitched views (text now gets larger relative to the map when it's in the distance, in order to stay more legible), so it's likely those changes are affecting the behavior you're seeing.

Is it possible you could figure out how to trigger the behavior using the easeTo animation API? That might help us reproduce the problem here. Also, in your original post you showed a layer with text-allow-overlap: true, but I don't see that in the JSFiddle -- that's a pretty important property for label collision behavior. Sorry if I'm missing what you were trying to show...

These two debugging options might help you understand what's going on, too:

    map.showCollisionBoxes = true;
    map.showTileBoundaries = true;

The first one will show the boxes that are used for detecting when labels collide with each other. When the boxes go from green to red, that means a collision has been detected and the label will be hidden. The second one shows the boundaries between different tiles of the map -- I suspect what you might see is that labels are disappearing one tile at a time (which might be a good hint about what's going wrong).

@flypdx
Copy link
Author

flypdx commented Aug 7, 2017

Hi @ChrisLoer. Thanks for the additional info. The debugging options are helpful. I won't have time to investigate with the easeTo API this week...however...I created a new JSFiddle that better shows the bulk disappearance and text severing here (needs API key): https://jsfiddle.net/woupa6L0/3/

I'll try to find time to continue investigating....but please take a look at the new JSFiddle above ( includes map.showCollisionBoxes = true; & map.showTileBoundaries = true;).

Also....text-allow-overlap: true or false produces the same result.

untitled

@ChrisLoer
Copy link
Contributor

ChrisLoer commented Aug 7, 2017

Thanks, @flypdx I can see the problem very easily in the new JSFiddle. It does look like a whole tile is getting dropped at once, but the "tile debug boundaries" aren't showing it because the symbols are actually in a GeoJSON tile at zoom level 20, while the tile debug view is showing the boundaries of the base map vector tiles, which max out at zoom level 16. I'll investigate...

@ChrisLoer ChrisLoer changed the title Feature Type Symbols Disappear on Pitch and Rotation CollisionTile minScale/maxScale range is too small for overzoomed tiles, causing labels to disappear Aug 7, 2017
@ChrisLoer ChrisLoer self-assigned this Aug 7, 2017
@ChrisLoer
Copy link
Contributor

Aha! So the problem is that in order to make collision detection faster, we only calculate collisions over a scale range from 50% to 200%. In pitched views, we adjust that range based on how far the tile is from the camera. The problem here is that the tile is overzoomed (the GeoJSON source defaults to a maxzoom of 18, and we're showing at zoom 20 in your example). From the renderer's point of view, an overzoomed tile is really big (bigger than the viewport), and since it's pitched, that means there's a very large difference in the "effective" scale between something in the distance (much smaller) and something in the foreground (much larger). Our 4x (from 50% to 200%) scale range isn't big enough to handle it, and that's why a bunch of labels get dropped.

Luckily, I think there's an easy workaround that should work for you. Just add this line to your GeoJSON source:

"maxzoom": 20

(or maybe even higher, depending on what zoom level you want to support). Under the hood, that will make GL JS generate more (higher-zoom) tiles out of the GeoJSON you provide.

This is closely related to issue #5095, and like that one, we'll fix the underlying issue with our work on global/viewport collision detection.

@flypdx
Copy link
Author

flypdx commented Aug 7, 2017

Thanks, @ChrisLoer you rock! "maxzoom": 20 fixed the issue.... a huge relief on our side. Will keep an eye on issue #5095

@ChrisLoer
Copy link
Contributor

#5150 fixed this by completely removing the minScale/maxScale concept.

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

3 participants