sgelb
sgelb

Reputation: 665

Mapbox GL JS: Show all labels completely inside non-interactive map

Labels across the visble map's edges are only shown partially. This is of course expected behaviour and not a problem when panning is possible.

But for non-interactive maps, like in this Mapbox example, panning is disabled. There's no way for users to ever see those labels completely. That leaves most of them as useless clutter.

For this case, when panning is disabled, I'd prefer to either render those labels completely inside the visible map or not at all. Any ideas?

Upvotes: 1

Views: 677

Answers (1)

Lucas Wojciechowski
Lucas Wojciechowski

Reputation: 3802

The symbol-avoid-edges property provides the behaviour for which you're asking. Applying this property to all symbol layers in your base layer will require some light scripting or elbow grease.

There is no existing way to prevent labels from intersecting with the viewport edges.

Upvotes: 2

Related Questions