diff --git a/web/components/visualization/results-map.js b/web/components/visualization/results-map.js index 3fdb314a379dd09270ef2887265830b8bdb8d1d9..98e2961cf2dae8dcc294abbfe8eabd63377bb9d6 100644 --- a/web/components/visualization/results-map.js +++ b/web/components/visualization/results-map.js @@ -30,7 +30,10 @@ class MapComponent { let election = await this.ElectionModel.getElection( this.parent.parent.round.ElectionID ); - await this.initMap(election.MapSectionFile.replace("web/", ""), this.colorSections); + await this.initMap( + election.MapSectionFile.replace("web/", ""), + this.colorSections + ); } async initMap(mapFile, colorationFunction) { @@ -118,6 +121,14 @@ class MapComponent { } async colorAreas(mapHandler, dataSource) { + for (let tile of dataSource.features) { + dataSource = mapHandler.colorTiles( + dataSource, + tile.properties.gid, + "", + "" + ); + } for (let area of mapHandler.parent.parent.results.areasResults) { if (area.status == mapHandler.parent.parent.filter) { let party = await mapHandler.PartyModel.getParty( @@ -129,15 +140,21 @@ class MapComponent { party.Name, party.Color ); - } else { - dataSource = mapHandler.colorTiles(dataSource, area.MapID, "", ""); } } return dataSource; } async colorSections(mapHandler, dataSource) { - mapHandler.parent.parent.results.areasResults.forEach(async (area) => { + dataSource.features.forEach((tile) => { + dataSource = mapHandler.colorTiles( + dataSource, + tile.properties.gid, + "", + "" + ); + }); + for (let area of mapHandler.parent.parent.results.areasResults) { for (let section of area.Sections) { if (section.status == mapHandler.parent.parent.filter) { let party = await mapHandler.PartyModel.getParty( @@ -149,11 +166,9 @@ class MapComponent { party.Name, party.Color ); - } else { - dataSource = mapHandler.colorTiles(dataSource, section.MapID, "", ""); } } - }); + } return dataSource; } @@ -165,7 +180,6 @@ class MapComponent { if (f.properties.gid === gid) { f.properties.partyName = partyName; f.properties.color = color; - break; } }