|
@@ -13,60 +13,70 @@ import Leaflet from './Leaflet';
|
|
|
import Google from './Google';
|
|
|
import Mapbox from './Mapbox';
|
|
|
|
|
|
+import Pigeons from './test/Pigeons';
|
|
|
+import Leaflets from './test/Leaflets';
|
|
|
+
|
|
|
import {calcDistance} from './helpers/distance';
|
|
|
import {longitude, latitude} from "./config/variables";
|
|
|
|
|
|
|
|
|
export class App extends React.Component{
|
|
|
- constructor(props) {
|
|
|
- super(props)
|
|
|
+ constructor(props) {
|
|
|
+ super(props)
|
|
|
|
|
|
- this.state = {
|
|
|
- mapConfig: {
|
|
|
- zoom: 15,
|
|
|
- path: [],
|
|
|
- coords: [latitude, longitude],
|
|
|
- defaultZoom: 15,
|
|
|
- distance: 0,
|
|
|
- }
|
|
|
- }
|
|
|
+ this.state = {
|
|
|
+ mapConfig: {
|
|
|
+ zoom: 15,
|
|
|
+ path: [],
|
|
|
+ coords: [latitude, longitude],
|
|
|
+ defaultZoom: 15,
|
|
|
+ distance: 0,
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- updateMapState = (key, value) => {
|
|
|
- let mapConfigCopy = JSON.parse(JSON.stringify(this.state.mapConfig));
|
|
|
- mapConfigCopy[key] = value;
|
|
|
- this.setState({mapConfig: mapConfigCopy})
|
|
|
- }
|
|
|
+ updateMapState = (key, value) => {
|
|
|
+ let mapConfigCopy = JSON.parse(JSON.stringify(this.state.mapConfig));
|
|
|
+ mapConfigCopy[key] = value;
|
|
|
+ this.setState({mapConfig: mapConfigCopy})
|
|
|
+ }
|
|
|
|
|
|
- getDistance = () => {
|
|
|
- let dst = calcDistance(this.state.mapConfig.path)
|
|
|
- this.updateMapState("distance", dst)
|
|
|
- }
|
|
|
+ getDistance = () => {
|
|
|
+ let dst = calcDistance(this.state.mapConfig.path)
|
|
|
+ this.updateMapState("distance", dst)
|
|
|
+ }
|
|
|
|
|
|
- render(){
|
|
|
- return (
|
|
|
- <div>
|
|
|
- <Router>
|
|
|
- <Navigation />
|
|
|
- <Switch>
|
|
|
- <Route path="/" exact component={Home} />
|
|
|
- <Route path="/about" exact component={About} />
|
|
|
- <Route exact path="/pigeon-map" render={() =>
|
|
|
- <Pigeon
|
|
|
- mapConfig={this.state.mapConfig}
|
|
|
- updateMapState={this.updateMapState}
|
|
|
- getDistance={this.getDistance}
|
|
|
- />}
|
|
|
- />
|
|
|
- <Route path="/map-gl" exact component={MapGL} />
|
|
|
- <Route path="/leaflet" exact component={Leaflet} />
|
|
|
- <Route path="/google-map" exact component={Google} />
|
|
|
- <Route path="/mapbox" exact component={Mapbox} />
|
|
|
- </Switch>
|
|
|
- <Footer />
|
|
|
- </Router>
|
|
|
- </div>
|
|
|
- )
|
|
|
- }
|
|
|
+ render(){
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <Router>
|
|
|
+ <Navigation />
|
|
|
+ <Switch>
|
|
|
+ <Route path="/" exact component={Home} />
|
|
|
+ <Route path="/about" exact component={About} />
|
|
|
+ <Route exact path="/pigeon-map" render={() =>
|
|
|
+ <Pigeon
|
|
|
+ mapConfig={this.state.mapConfig}
|
|
|
+ updateMapState={this.updateMapState}
|
|
|
+ getDistance={this.getDistance}
|
|
|
+ />}
|
|
|
+ />
|
|
|
+ <Route path="/pigeon-map/test" exact component={Pigeons} />
|
|
|
+
|
|
|
+ <Route path="/map-gl" exact component={MapGL} />
|
|
|
+
|
|
|
+ <Route path="/leaflet" exact component={Leaflet} />
|
|
|
+ <Route path="/leaflet/test" exact component={Leaflets} />
|
|
|
+
|
|
|
+ <Route path="/google-map" exact component={Google} />
|
|
|
+
|
|
|
+ <Route path="/mapbox" exact component={Mapbox} />
|
|
|
+
|
|
|
+ </Switch>
|
|
|
+ <Footer />
|
|
|
+ </Router>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
}
|