mapbox / mapbox/mapbox-gl-js

Support pitch top-level interpolate expression

Open
#13,615 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Motivation

I would like to disable terrain when the camera is pointing down so that the map doesn't deform, specially when showing a raster layer featuring baked-in text. I would like to smoothly transition it in and out with an expression using pitch.

ImageImage

Notice how the pink line is wobbly on the first picture. This is particularly obvious when moving the camera around.

Design Alternatives

There is obviously this rather tedious option:

map.on('pitch', () => {
    const pitch = map.getPitch();
    
    const newExaggeration = pitch > 30 ? (pitch / 30) : 1.0;

    map.setTerrain({
        'source': 'mapbox-dem',
        'exaggeration': newExaggeration
    });
});
Mock-Up
      terrain: {
        source: 'mapbox-dem',
        exaggeration: ['interpolate', ['linear'], ['pitch'], 0, 0, 20, 1],
      },
Concepts

This option would fit nicely with the existing top-level zoom interpolation logic

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing top-level zoom interpolation logic mentioned in the issue, then trace how terrain exaggeration is read and applied. Implement the requested pitch-based interpolation for terrain exaggeration and verify that terrain transitions as camera pitch changes without requiring a pitch event handler.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
computer-graphics, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.