Skip to content

symbol-placement: line-center produces incorrect results at some zoom levels #9628

@mike-unearth

Description

@mike-unearth

mapbox-gl-js version: 1.9.1

browser: Chrome 81

Steps to Trigger Behavior

  1. Create a geojson source with a LineString feature
  2. Create a text layer for the source with symbol-placement: line-center
  3. Zoom in

Link to Demonstration

https://jsfiddle.net/37sgzkme/

Expected Behavior

My understanding is that the label should appear at the center of the geometry at all zoom levels.

Actual Behavior

The label appears at the center of the geometry at all zoom levels below 18. Above 18, multiple labels are rendered along the line, or in some cases the single label simply moves to a new location on the line.

Increasing the source buffer size definitely helps, and in fact solves the issue for some simple lines, but my dataset is dynamic.

The following two lines in symbol_layout.js are certainly eye-catching, but I haven't yet figured out exactly what's going wrong and why.

//   4. `text-size` at zoom level 18. Used for something line-symbol-placement-related.
...
sizes.textMaxSize = unevaluatedLayoutValues['text-size'].possiblyEvaluate(new EvaluationParameters(18));

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions