Using 3d terrain elevation in a 3rd party basemap style throws javascript error
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
**mapbox-gl-js version**: 3.12.0
**browser**: Chrome
### Steps to Trigger Behavior
1. Setup a terrain in your map:
```
map.addSource('mapbox-dem', {
'type': 'raster-dem',
'url': 'mapbox://mapbox.mapbox-terrain-dem-v1',
'tileSize': 512,
'maxzoom': 14
});
// add the DEM source as a terrain layer with exaggerated height
map.setTerrain({ 'source': 'mapbox-dem', 'exaggeration': 1.5 });
```
2. Use a 3rd party basemap style such as USGS or World Topo (see code in demonstration link below)
3. Notice the error in your javascript console `Uncaught TypeError: Cannot read properties of undefined (reading 'get')`
### Link to Demonstration
https://codepen.io/Matt-Palmerlee/pen/NWZrVoJ
### Expected Behavior
The basemap style is changed and elevation is shown without Javascript errors
### Actual Behavior
Elevation seems to display fine, however javascript error is thrown:
```
Uncaught TypeError: Cannot read properties of undefined (reading 'get')
at qs.update (terrain.ts:386:48)
...
```
Perhaps the check on [this line in terrain.ts](https://github.com/mapbox/mapbox-gl-js/blob/main/src/terrain/terrain.ts#L369) should also check style.terrain.properties?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the CodePen example, a raster-dem terrain source, and a third-party basemap style. Inspect src/terrain/terrain.ts around the style.terrain check near line 369 and the failing update code around line 386; done means terrain elevation and style changes work without a JavaScript error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100