I have following collection of lat/long in java-script array.
locData=[[32.0770488,34.7958072],[32.0776696,34.7683079],[32.0776696,34.7683079],[32.07849,34.773982],[32.07849,34.773982],[32.07849,34.773982],[32.07849,34.773982],[32.07849,34.773982],[32.07849,34.773982],[32.07849,34.773982],[32.07849,34.773982],[32.077795,34.774825],[32.077795,34.774825],[32.077589,34.774565],[32.077589,34.774565],[32.077795,34.774825],[32.077795,34.774825],[32.077589,34.774565],[32.077795,34.774825],[32.077589,34.774565],[32.077795,34.774825],[32.077795,34.774825],[32.077589,34.774565],[32.077589,34.774565],[32.077589,34.774565],[32.077589,34.774565],[32.077589,34.774565],[32.083678,34.775796],[32.079743,34.770179],[32.079743,34.770179],[32.079743,34.770179],[32.079743,34.770179],[32.079743,34.770179],[32.079743,34.770179],[32.079743,34.770179],[32.079743,34.770179],[32.079743,34.770179],[32.079743,34.770179],[32.079743,34.770179],[32.079743,34.770179],[32.0776696,34.7683079],[32.0776696,34.7683079],[32.0776696,34.7683079],[32.0776696,34.7683079],[32.0776696,34.7683079],[32.0776696,34.7683079],[32.0776696,34.7683079],[32.0776696,34.7683079],[32.115119,34.818128],[31.749309,35.236047]];
Now I want to find duplicate lat/long from this array and generate new array which contains duplicate array list.
My Code:
for (var i = 0; i < locData.length; i++) {
var title = JSON.stringify(titleData[i]);
var id = JSON.stringify(ids[i]);
title = title.replace(/[[\]/"]/g, "");
id = id.replace(/[[\]/"]/g, "");
var count = 0;
var multiArray = [];
for(var j=0; j<locData.length; j++){
if(locData[i][0] === locData[j][0] && locData[i][1] === locData[j][1]){
count++;
if(count>1){
//alert(locData[i]);
//console.log(locData[i]);
multiArray.push(locData[i]);
}
}
}
console.log(multiArray);
}
But is not generating result as I want it with duplicates with unique each time is it any way?