admin管理员组文章数量:1313991
I am a newbie in terms of react, js and deck.gl and would like to run the basic getting started example from deck.gl:
Where do I put this code, which extension do I use, do I need other files e.g. app.js
to run this:
import DeckGL from 'deck.gl/react';
import {ArcLayer} from 'deck.gl';
const flights = new ArcLayer({
id: 'flights',
data: [] // Some flight points
});
<DeckGL width={1920} height={1080} layers={[flights]} />
I am really sorry for the vague question, but I really would like the necessary steps to get this examples working on a Mac. Do I need to install a react app? How does this work?
I am a newbie in terms of react, js and deck.gl and would like to run the basic getting started example from deck.gl:
Where do I put this code, which extension do I use, do I need other files e.g. app.js
to run this:
import DeckGL from 'deck.gl/react';
import {ArcLayer} from 'deck.gl';
const flights = new ArcLayer({
id: 'flights',
data: [] // Some flight points
});
<DeckGL width={1920} height={1080} layers={[flights]} />
I am really sorry for the vague question, but I really would like the necessary steps to get this examples working on a Mac. Do I need to install a react app? How does this work?
Share Improve this question edited May 14, 2017 at 16:07 Preview 35.8k10 gold badges95 silver badges113 bronze badges asked Mar 9, 2017 at 13:58 user7684764user76847642 Answers
Reset to default 6We have now setup pretty straightforward examples you can directly clone and start toying with, even if you don't have any previous knowledge of reactjs or deck.gl.
You just need to go to one of the examples, let's do it with the webpack 2 hello-world.
Before anything, you need to go to the MapBox website, create an account and generate an API key, that will be used to render the tiles of the map. Once you have it, just export it as an environment variable:
export MAPBOX_ACCESS_TOKEN=42eufr5aeoushanoeu
Then you can actually start doing the following:
git clone [email protected]:uber/deck.gl.git
cd examples/hello-world-webpack2
npm install
npm start
And you should be good to go, the app.js
file is the only thing to change in order to change layers or the map in itself.
Disclaimer: I work at Uber with the Visualization team that made deck.gl.
EDIT:
Here is a good recent walkthrough of someone experimenting with deck.gl
Source: @github.NghiaTranUIT
Looking at the examples there are two things to note.
- You need data within the data field
- You need react and other dependences
From getting started
import DeckGL from 'deck.gl/react';
import {ArcLayer} from 'deck.gl';
const flights = new ArcLayer({
id: 'flights',
data: [] // data field needs to have data
});
<DeckGL width={1920} height={1080} layers={[flights]} />
they omit how the data should be structured (hence where you might have problems).
The other thing is that the library is dependent on using react
from hello-world-webpack2
package.json
"dependencies": {
"deck.gl": "^4.0.0-rc.3",
"immutable": "^3.8.1",
"luma.gl": "^3.0.0",
"react": "^15.4.1",
"react-dom": "^15.4.1",
"react-map-gl": "^2.0.0"
},
So following those examples, you'll need to have react to run your own project with deck.gl.
I'd remend looking at the examples on github to get a better understanding on how to run a starter project.
本文标签: javascriptHow to run the Deckgl getting started examplesStack Overflow
版权声明:本文标题:javascript - How to run the Deck.gl getting started examples - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741932647a2405666.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论