fix(map): group national view by live GPS province

This commit is contained in:
lingniu
2026-08-03 21:49:42 +08:00
parent 30fef937b0
commit dc5f88cf16
6 changed files with 153 additions and 60 deletions
+13 -4
View File
@@ -12,13 +12,22 @@ dashboard = {
{ vin: 'VIN-X-1', plateNumber: '观光车001', online: false, dailyMileageKm: 0, locationAvailable: false }
]
};
const areaNode = {
groupByPosition(points) {
return [
{ subFeatureIndex: 0, subFeature: { properties: { adcode: '440000', name: '广东省', center: [113.2, 23.1] } }, points: points.filter(point => point.vin === 'VIN-GD-1') },
{ subFeatureIndex: 1, subFeature: { properties: { adcode: '330000', name: '浙江省', center: [120.2, 30.3] } }, points: points.filter(point => point.vin === 'VIN-ZJ-1') }
];
}
};
vehicleProvinceSummary = aggregateVehicleProvinces(areaNode);
const summary = buildVehicleProvinceNodes();
assert.equal(summary.nodes.length, 2);
assert.equal(summary.unassigned, 1);
assert.equal(summary.unassigned, 2);
const guangdong = summary.nodes.find(node => node.nameZh === '广东');
assert.equal(guangdong.count, 2);
assert.equal(guangdong.count, 1);
assert.equal(guangdong.online, 1);
assert.equal(guangdong.dist, 15);
assert.equal(guangdong.dist, 10);
map = { getZoom: () => 4.8 };
assert.equal(vehicleNodes().length, 2);
@@ -32,7 +41,7 @@ assert.equal(vehicleNodes().reduce((sum, node) => sum + node.count, 0), 2);
const sandbox = {
assert,
console,
document: { addEventListener() {} },
document: { addEventListener() {}, querySelector() {}, createElement() { return {}; }, head: { appendChild() {} } },
window: {},
setInterval() {},
clearInterval() {}