getMarshrutPoints = (data)=> {
let marshrut = new Array();
let eventsArray = new Array();
if(data.length !== 0){
data.map((key)=>{
if(key.events.length>0){
key.events.map(ev=>{
let json = {};
json.from = ev.from;
json.ignitionOn = ev.ignitionOn;
json.lat = key.gpsData.latitude;
json.lng = key.gpsData.longitude;
json.name =ev.name;
json.timestamp = key.timestamp;
eventsArray.push(json)
})
}
if(key.gpsData!== null){
if (key.gpsData.latitude==0 && key.gpsData.longitude==0){
null
}else{
return marshrut.push([key.gpsData.latitude, key.gpsData.longitude])
}
}
})
}
marshrut = (marshrut.length == 0)?null:marshrut;
if (checkKey(marshrut)){
let marker_position = {
latitude: marshrut[marshrut.length-1][0],
longitude: marshrut[marshrut.length-1][1]
}
this.setState({
marker_position: marker_position,
})
}
console.log(eventsArray)
this.setState({
marshrut: marshrut,
events: eventsArray,
})
}
selectedGraph = (value)=>{
let array_charts = [], newVal = new Array; newVal = value.concat();
for (let i=0; i <value.length; i++){
if(value[i] == 'speed'){
if(Array.isArray(this.state.speed_charts)){
array_charts.push(this.state.speed_charts)
}
}else{
if(Array.isArray(this.state.chart_data[value[i]])){
array_charts.push(this.state.chart_data[value[i]])
}
}
}
this.setState({
route_detail: array_charts,
selectedGraph: newVal,
});
}
а как спрашивать, это уже вам решать