-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reorganize get-started examples (#971)
- Loading branch information
1 parent
c293324
commit 439e7ec
Showing
30 changed files
with
132 additions
and
111 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div align="center"> | ||
<img src="https://avatars3.githubusercontent.com/u/2105791?v=3&s=200" /> | ||
</div> | ||
|
||
## react-map-gl example with React Component | ||
|
||
The configuration showcased here is a bit less straightforward than its browserify | ||
equivalent due to some incompatibilities with mapbox-gl, but has been kept at a | ||
strict minimum. | ||
|
||
You should keep in mind that it is a development configuration, and probably | ||
should be tweaked a bit for production optimization, there is plenty ressources | ||
on the subject and are not in the scope of this example. |
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
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,30 @@ | ||
/* global document */ | ||
import React, {useState} from 'react'; | ||
import {render} from 'react-dom'; | ||
import MapGL from 'react-map-gl'; | ||
|
||
const MAPBOX_TOKEN = ''; // Set your mapbox token here | ||
|
||
function Root() { | ||
const [viewport, setViewport] = useState({ | ||
latitude: 37.8, | ||
longitude: -122.4, | ||
zoom: 14, | ||
bearing: 0, | ||
pitch: 0 | ||
}); | ||
|
||
return ( | ||
<MapGL | ||
{...viewport} | ||
width="100vw" | ||
height="100vh" | ||
mapStyle="mapbox://styles/mapbox/dark-v9" | ||
onViewportChange={setViewport} | ||
mapboxApiAccessToken={MAPBOX_TOKEN} | ||
/> | ||
); | ||
} | ||
|
||
document.body.style.margin = 0; | ||
render(<Root />, document.body.appendChild(document.createElement('div'))); |
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,20 @@ | ||
{ | ||
"scripts": { | ||
"start": "webpack-dev-server --progress --hot --open" | ||
}, | ||
"dependencies": { | ||
"react": "^16.8.0", | ||
"react-dom": "^16.8.0", | ||
"react-map-gl": "^5.1.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.0.0", | ||
"@babel/preset-env": "^7.0.0", | ||
"@babel/preset-react": "^7.0.0", | ||
"babel-loader": "^8.0.0", | ||
"html-webpack-plugin": "^3.0.7", | ||
"webpack": "^4.20.0", | ||
"webpack-cli": "^3.1.2", | ||
"webpack-dev-server": "^3.1.0" | ||
} | ||
} |
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,36 @@ | ||
const webpack = require('webpack'); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
|
||
entry: { | ||
app: './app.js' | ||
}, | ||
|
||
devtool: 'source-map', | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
// Compile ES2015 using babel | ||
test: /\.js$/, | ||
exclude: [/node_modules/], | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: { | ||
presets: ['@babel/env', '@babel/react'] | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
|
||
// Optional: Enables reading mapbox token from environment variable | ||
plugins: [ | ||
new HtmlWebpackPlugin({title: 'react-map-gl Example'}), | ||
new webpack.EnvironmentPlugin(['MapboxAccessToken']) | ||
] | ||
}; |
Oops, something went wrong.