|
@@ -19,7 +19,8 @@ export default class Leaflet extends React.Component{
|
|
|
path: testPath,
|
|
|
distance: 0,
|
|
|
pathKey: "",
|
|
|
- pathKeys: []
|
|
|
+ pathKeys: [],
|
|
|
+ savePathKey: "-"
|
|
|
}
|
|
|
|
|
|
componentDidMount(){
|
|
@@ -74,7 +75,12 @@ export default class Leaflet extends React.Component{
|
|
|
'Content-Type': 'application/json',
|
|
|
},
|
|
|
body: json
|
|
|
- })
|
|
|
+ }).then(res => res.json)
|
|
|
+ .then(data => {
|
|
|
+ let pathKeyCopy = this.state.pathKeys.slice();
|
|
|
+ pathKeyCopy.push(this.state.savePathKey);
|
|
|
+ this.setState({pathKeys: pathKeyCopy})
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
setSavePathKey = (event) => {
|
|
@@ -83,7 +89,6 @@ export default class Leaflet extends React.Component{
|
|
|
|
|
|
newPathPoint = event => {
|
|
|
const { lat, lng } = event.latlng
|
|
|
- console.log("Clicked at", lat, "/", lng)
|
|
|
let pathCopy = this.state.path.slice();
|
|
|
pathCopy.push([lat, lng]);
|
|
|
this.setState({path: pathCopy})
|
|
@@ -92,7 +97,6 @@ export default class Leaflet extends React.Component{
|
|
|
|
|
|
updateMarker = (idx, event) => {
|
|
|
let {lat, lng} = event.target.getLatLng();
|
|
|
- console.log(lat, lng, idx)
|
|
|
let pathCopy = this.state.path.slice();
|
|
|
pathCopy[idx] = [lat, lng]
|
|
|
this.setState({path: pathCopy})
|