function func(e){
e.currentTarget.parentElement.removeChild(e.currentTarget);
}
class Sorter {
constructor() {
this.array = [];
}
add(element) {
this.array[this.array.length+1]=element;
return this.array.length+1;
}
}
var arr = [
{ID: "123", lat: "55.680024", lng: "37.558505"},
{ID: "123", lat: "55.680024", lng: "37.558505"},
{ID: "987", lat: "55.783861", lng: "37.536533"},
{ID: "987", lat: "55.783861", lng: "37.536533"}
];
console.log( convert(arr));
function convert(arr){
var newarr = [];
arr.map((e)=>{
for(var i = 0;i < newarr.length;i++)
if(newarr[i].ID == e.ID){
newarr[i].Coords.push({lat:e.lat,lng:e.lng});
return;
}
newarr.push({ID:e.ID,Coords:[{lat:e.lat,lng:e.lng}]});
});
return newarr;
}