// let arr = [1, 2, 3, 4, 6, 7, 8, 9, 10]
// let aaa = []
// let s = 0
// for (let i = 0; i < arr.length; i++) {
// let num = 0
// if (i != arr.length - 1) num = diff(arr[i], arr[i + 1])
// if (num > 1) {
// aaa.push(arr.slice(s, s = i + 1))
// }
// }
// console.log(s)
// if (s <= arr.length) aaa.push(arr.slice(s, arr.length))
// console.log(aaa)
// function diff(time1, time2) {
// return time2 - time1
// }
let sss = [
{ lat: 22.63876152, lng: 113.92721558, createTime: "2610-06-12 06:10:41" },
{ lat: 22.63874435, lng: 113.92731476, createTime: "2610-06-12 06:12:41" },
{ lat: 22.63875771, lng: 113.92731476, createTime: "2610-06-12 06:13:41" }
]
let arrIndex =0
let polylineArr = []
sss.reduce(function(prev, cur, index, arr) {
let min = timeDifference(prev, cur.createTime)
if (min >= 2) {
polylineArr.push(sss.slice(arrIndex, arrIndex = index))
}
return cur.createTime
}, sss[0].createTime)
console.log(arrIndex)
if (arrIndex <= sss.length) polylineArr.push(sss.slice(arrIndex, sss.length))
console.log(polylineArr)
function timeDifference(time1, time2) {
let date1 = new Date(time1)
let date2 = new Date(time2)
let diffs = date2.getTime() - date1.getTime()
let min = Math.floor(diffs / (60 * 1000))
return min
}
console