Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add terrain example to the website (#4298)
- Loading branch information
1 parent
da8d4e4
commit 61cd95d
Showing
14 changed files
with
183 additions
and
241 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* eslint-disable max-statements */ | ||
import React from 'react'; | ||
import {render} from 'react-dom'; | ||
import DeckGL from '@deck.gl/react'; | ||
|
||
import {TerrainLayer} from '@deck.gl/geo-layers'; | ||
|
||
// Set your mapbox token here | ||
const MAPBOX_TOKEN = process.env.MapboxAccessToken; // eslint-disable-line | ||
|
||
const INITIAL_VIEW_STATE = { | ||
latitude: 46.24, | ||
longitude: -122.18, | ||
zoom: 11.5, | ||
bearing: 140, | ||
pitch: 60 | ||
}; | ||
|
||
const TERRAIN_IMAGE = `https://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.png?access_token=${MAPBOX_TOKEN}`; | ||
const SURFACE_IMAGE = `https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}@2x.png?access_token=${MAPBOX_TOKEN}`; | ||
|
||
// https://docs.mapbox.com/help/troubleshooting/access-elevation-data/#mapbox-terrain-rgb | ||
// Note - the elevation rendered by this example is greatly exagerated! | ||
const ELEVATION_DECODER = { | ||
rScaler: 6553.6, | ||
gScaler: 25.6, | ||
bScaler: 0.1, | ||
offset: -10000 | ||
}; | ||
|
||
export default function App({ | ||
surfaceImage = SURFACE_IMAGE, | ||
wireframe = false, | ||
initialViewState = INITIAL_VIEW_STATE | ||
}) { | ||
const layer = new TerrainLayer({ | ||
id: 'terrain', | ||
minZoom: 0, | ||
maxZoom: 23, | ||
strategy: 'no-overlap', | ||
elevationDecoder: ELEVATION_DECODER, | ||
terrainImage: TERRAIN_IMAGE, | ||
surfaceImage, | ||
wireframe, | ||
color: [255, 255, 255] | ||
}); | ||
|
||
return <DeckGL initialViewState={initialViewState} controller={true} layers={[layer]} />; | ||
} | ||
|
||
export function renderToDOM(container) { | ||
render(<App />, container); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.