Basic React + Vite app showing a TerrainLayer (Mapbox elevation + satellite texture) and a SolidPolygonLayer draped over the terrain using TerrainExtension.
- Create
.env.local(copy from.env.example) and set your Mapbox token:VITE_MAPBOX_TOKEN=pk.your_token_here - Install deps & run:
npm install npm run dev - Open the printed local URL (usually http://localhost:5173).
Click the orange polygon to see console logs (info.index, info.object). You'll see that the console shows an erroneous pick, with a high index value.
- If no token is provided you'll still see a warning and terrain tiles will also fail (they require the same token) – add a valid token for full functionality.
- Adjust
initialViewStateorpolygonDatainsrc/App.jsxas needed.