|
@@ -9,8 +9,8 @@ import {
|
|
|
} from "react-leaflet";
|
|
|
import "./../css/maps.css";
|
|
|
import {calcDistance} from "./../helpers/distance";
|
|
|
-import {longitude, latitude, mapWidth, mapHeight, testPath} from "./../config/variables";
|
|
|
-import {Button, Input} from "reactstrap";
|
|
|
+import {longitude, latitude, mapWidth, mapHeight} from "./../config/variables";
|
|
|
+import {Button} from "reactstrap";
|
|
|
import PathButtons from "./../PathButtons";
|
|
|
|
|
|
export default class Leaflet extends React.Component{
|
|
@@ -57,14 +57,27 @@ export default class Leaflet extends React.Component{
|
|
|
|
|
|
render() {
|
|
|
const position = [this.state.latitude, this.state.longitude]
|
|
|
- let markers = this.props.markers
|
|
|
- if (markers){
|
|
|
+ let testMarkers = this.props.markers
|
|
|
+ let markers = <></>
|
|
|
+ if (testMarkers){
|
|
|
markers = this.props.markers.map((pos, idx) =>
|
|
|
<Marker position={pos} key={idx}></Marker>
|
|
|
)
|
|
|
}else{
|
|
|
- markers = <div></div>
|
|
|
+ markers = this.state.path.map((pos, idx) =>
|
|
|
+ <Marker
|
|
|
+ position={pos}
|
|
|
+ draggable
|
|
|
+ key={idx}
|
|
|
+ onDragend={(e) => this.updateMarker(idx, e)}
|
|
|
+ >
|
|
|
+ <Popup>
|
|
|
+ {idx}
|
|
|
+ </Popup>
|
|
|
+ </Marker>
|
|
|
+ )
|
|
|
}
|
|
|
+
|
|
|
return (
|
|
|
<div>
|
|
|
<div className="map">
|
|
@@ -81,19 +94,6 @@ export default class Leaflet extends React.Component{
|
|
|
/>
|
|
|
<ZoomControl position="bottomright" />
|
|
|
|
|
|
- {this.state.path.map((pos, idx) =>
|
|
|
- <Marker
|
|
|
- position={pos}
|
|
|
- draggable
|
|
|
- key={idx}
|
|
|
- onDragend={(e) => this.updateMarker(idx, e)}
|
|
|
- >
|
|
|
- <Popup>
|
|
|
- {idx}
|
|
|
- </Popup>
|
|
|
- </Marker>
|
|
|
- )}
|
|
|
-
|
|
|
<Polyline color="grey" positions={this.state.path} />
|
|
|
|
|
|
{markers}
|