Skip to content

Instantly share code, notes, and snippets.

@steelydylan
Last active July 20, 2018 06:02
Show Gist options
  • Save steelydylan/2e0e3a560744e2dac6c03f3416d801dd to your computer and use it in GitHub Desktop.
Save steelydylan/2e0e3a560744e2dac6c03f3416d801dd to your computer and use it in GitHub Desktop.
Harmoware-VIS 最小サンプル
// app.js mapboxを使用する場合のサンプル
import React from 'react';
import {
Container, connectToHarmowareVis,
HarmoVisLayers, MovesLayer, DepotsLayer,
MovesInput, DepotsInput, SimulationDateTime,
PauseButton, ForwardButton, ReverseButton, AddMinutesButton,
ElapsedTimeRange, SpeedRange
} from 'harmoware-vis';
const MAPBOX_TOKEN = XXXXXXXXXX; //mapbox.com から取得したAccesstoken
class App extends Container {
render() {
const { viewport, actions, routePaths, lightSettings,
animatePause, animateReverse, settime, secperhour, timeBegin, timeLength,
movesbase, movedData, clickedObject, depotsData } = this.props;
return (
<div>
<div className="controller_area"> //コントローラーエリア
<ul>
<li><MovesInput actions={actions} /></li>
<li><DepotsInput actions={actions} /></li>
<li>{animatePause ?
<PlayButton actions={actions} /> :
<PauseButton actions={actions} />}</li>
<li>{animateReverse ?
<ForwardButton actions={actions} /> :
<ReverseButton actions={actions} />}</li>
<li><AddMinutesButton addMinutes={-5} actions={actions} /></li>
<li><AddMinutesButton addMinutes={5} actions={actions} /></li>
<li><SimulationDateTime timeBegin={timeBegin} settime={settime} /></li>
<li><ElapsedTimeRange settime={settime} timeLength={timeLength} actions={actions} /></li>
<li><SpeedRange secperhour={secperhour} actions={actions} /></li>
</ul>
</div>
<div className="harmovis_area"> //シュミレーションエリア
<HarmoVisLayers
viewport={viewport} actions={actions}
mapboxApiAccessToken={MAPBOX_TOKEN}
layers={[
new MovesLayer({ routePaths, movesbase, movedData, clickedObject, actions, }),
new DepotsLayer({ depotsData, }),
]}
/>
</div>
</div>
);
}
}
export default connectToHarmowareVis(App);
import { render } from 'react-dom';
import { reducer } from 'harmoware-vis';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import React from 'react';
import App from './app';
const store = createStore(reducer);
render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('app')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment