|
@@ -5,6 +5,7 @@ import apiKey from './../config/googleApiKey.js';
|
|
|
import {calcDistance} from './../helpers/distance';
|
|
|
import {longitude, latitude, mapWidth, mapHeight, markerIcon, testPath} from "./../config/variables";
|
|
|
import {Button} from "reactstrap";
|
|
|
+import PathButtons from "./../PathButtons";
|
|
|
|
|
|
const svgStyle = {
|
|
|
top: "-20",
|
|
@@ -21,19 +22,27 @@ const Marker = ({ text }) =>
|
|
|
</div>;
|
|
|
|
|
|
export default class Google extends React.Component{
|
|
|
- state = {
|
|
|
- latitude: latitude,
|
|
|
- longitude: longitude,
|
|
|
- zoom: 15,
|
|
|
- distance: 0,
|
|
|
- path: testPath,
|
|
|
- draggable: true
|
|
|
+ constructor(props){
|
|
|
+ super(props);
|
|
|
+ this.state = {
|
|
|
+ latitude: latitude,
|
|
|
+ longitude: longitude,
|
|
|
+ zoom: 15,
|
|
|
+ distance: 0,
|
|
|
+ path: testPath,
|
|
|
+ draggable: true
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
componentDidUpdate(){
|
|
|
this.drawPath()
|
|
|
}
|
|
|
|
|
|
+ updateState = (key, value) => {
|
|
|
+ this.setState({[key]: value})
|
|
|
+ this.getDistance()
|
|
|
+ }
|
|
|
+
|
|
|
getRoute = (lng, lat) => {
|
|
|
let pathCopy = this.state.path.slice();
|
|
|
var end = [lat, lng];
|
|
@@ -166,6 +175,8 @@ export default class Google extends React.Component{
|
|
|
<p>
|
|
|
Distanz: {Math.round(this.state.distance*100)/100} km
|
|
|
</p>
|
|
|
+
|
|
|
+ <PathButtons updateState={this.updateState} path={this.state.path}/>
|
|
|
</div>
|
|
|
</div>
|
|
|
);
|