cmkimber / Elections_Ontario_App

Webapp to explore Elections Ontario data
0 stars 0 forks source link

districts on map not colour coded by party #3

Closed cmkimber closed 2 months ago

cmkimber commented 2 months ago

In the dev branch map_2018_data, the Leaflet map polygons for each district are currently black rather than coloured according to the party that won a given district in the selected year. This is because the information on winning parties is no longer contained in the shapefile itself but in a reactive dataframe called electoral_winners() that responds to changes in the selectInput() called input$year.

addPolygons needs to be restructured to colour according to the chosen year by responding to changes in electoral_winners().

cmkimber commented 2 months ago

Wholesale changes in the mapping workflow made to resolve this issue. The base map does not contain coloured polygons, but is simply a skeleton for reactive calls to addPolygons() through leafletProxy. Colouring the polygons responds to changes in the year selected, first by generating a temporary shapefile with information on the winning candidate joined to it and then by plotting apporpriately coloured polygons using addPolygons().

The highlighting of a selected district polygon is now responsive to changes in either the year or district selected, to ensure the highlighting remains in place if a different year is selected for the same district.