vue方法,longitude相同下,使用map做区分,打印arr1和arr2
deletesame() {
let arr = [
{
key: 1,
rootId: "33030200992007000001",
gbId: "33032796091320002029",
parentGbId: "330300000000",
parentName: "市本级",
name: "QS温州成鸿铝塑有限公司-通道处(环保)",
manufacturer: null,
model: "1",
firmware: null,
longitude: "120.448293",
latitude: "27.535628",
mark: 6,
status: 2,
videoSource: "温州雪亮工程",
videoProtocol: "雪亮私有接口",
},
{
key: 2,
rootId: "33030200992007000001",
gbId: "33032796091320002030",
parentGbId: "330300000000",
parentName: "市本级",
name: "QS(环评鉴定为非危废)温州格洛博电子有限公司-通道一(环保)",
manufacturer: null,
model: "1",
firmware: null,
longitude: "120.615262",
latitude: "27.516405",
mark: 6,
status: 1,
videoSource: "温州雪亮工程",
videoProtocol: "雪亮私有接口",
},
{
key: 3,
rootId: "33030200992007000001",
gbId: "33032796091320002031",
parentGbId: "330300000000",
parentName: "市本级",
name: "QS(环评鉴定为非危废)温州格洛博电子有限公司-通道二(环保)",
manufacturer: null,
model: "1",
firmware: null,
longitude: "120.616262",
latitude: "27.516405",
mark: 6,
status: 1,
videoSource: "温州雪亮工程",
videoProtocol: "雪亮私有接口",
},
{
key: 4,
rootId: "33030200992007000001",
gbId: "33032796091320002032",
parentGbId: "330300000000",
parentName: "市本级",
name: "QS温州信德电力配件有限公司-通道三(环保)",
manufacturer: null,
model: "1",
firmware: null,
longitude: "120.444538",
latitude: "27.538631",
mark: 6,
status: 2,
videoSource: "温州雪亮工程",
videoProtocol: "雪亮私有接口",
},
];
let map = new Map();
let arr1 = [];
let arr2 = [];
let list = [];
arr.forEach((item, index) => {
if (!map.has(item.longitude)) {
map.set(item.longitude, index);
arr1.push(item);
} else {
arr2.push(item);
}
});
console.log(arr1)
console.log(arr2)
list = [...arr1, ...arr2];
return list;
}
```