ITADN

raster-elevation-reference is ignored apparently

#13670Openyuriy-sng 创建于 2026-05-18
bug :lady_beetle:auto-triaged
Y
yuriy-sngcommented
### mapbox-gl-js version v3.24.0 ### Browser and version Chrome 148.0.7778.98 ### Expected behavior The raster tiles either drape the terrain below or just stay at one specific elevation (sea level) ### Actual behavior Tiles drape the terrain despite of [raster-elevation-reference](https://docs.mapbox.com/style-spec/reference/layers/#paint-raster-raster-elevation-reference) setting ### Link to the demonstration _No response_ ### Steps to trigger the unexpected behavior 1. Put the following in a JSBin, providing your mapbox token ```html <!doctype html> <html> <head> <meta charset="utf-8" /> <title>raster-elevation-reference repro</title> <link href="https://api.mapbox.com/mapbox-gl-js/v3.24.0/mapbox-gl.css" rel="stylesheet" /> <script src="https://api.mapbox.com/mapbox-gl-js/v3.24.0/mapbox-gl.js"></script> <style> body { margin: 0; } #map { width: 100vw; height: 100vh; } .buttons { position: absolute; top: 20px; left: 20px; z-index: 10; background: white; padding: 10px; border: 1px solid black; display: flex; gap: 10px; } button { padding: 8px 16px; cursor: pointer; font-weight: bold; border: 1px solid black; } </style> </head> <body> <div id="map"></div> <div class="buttons"> <div style="margin-bottom: 5px">Set raster-elevation-reference:</div> <div> <button onclick="setRef('sea')">sea</button> <button onclick="setRef('ground')">ground</button> </div> </div> <script> mapboxgl.accessToken = ''; const map = new mapboxgl.Map({ container: 'map', style: 'mapbox://styles/mapbox/satellite-v9', center: [2.7292467613902147, 39.79339118094808], zoom: 11.26592878922226, pitch: 75.49999999999982, bearing: 51.19999999999891, }); function setRef(v) { if (map.getLayer('osm-layer')) { map.setPaintProperty('osm-layer', 'raster-elevation-reference', v); } } map.on('load', () => { map.addSource('mapbox-dem', { type: 'raster-dem', url: 'mapbox://mapbox.mapbox-terrain-dem-v1', tileSize: 512, maxzoom: 14, }); map.setTerrain({ source: 'mapbox-dem', exaggeration: 1.5 }); map.addSource('osm', { type: 'raster', tiles: ['https://tile.openstreetmap.org/{z}/{x}/{y}.png'], bounds: [2.7, 39.75, 2.9, 39.85], }); map.addLayer({ id: 'osm-layer', type: 'raster', source: 'osm', paint: { 'raster-opacity': 0.6, 'raster-elevation-reference': 'sea', }, }); }); </script> </body> </html> ``` 2. Try clicking the buttons and observe how doesn't matter what, the tiles drape the terrain <img width="1055" height="654" alt="Image" src="https://github.com/user-attachments/assets/ef2f0110-e84c-4cae-8fda-5260a8b0b95a" />
0 条评论