The last requirement we need to implement, states that the application must change the colors of the polygons as the user clicks on the year buttons of the navigation bar. As before, we will achieve this through the year:change
custom event we'll add to the map that will be triggered by the navigation buttons, and handled by the shapes.
Microsoft.Maps.Events.addHandler(this._map, 'year:change', function(e) { self._changeYear(e.currentYear); });
The preceding lines, which we add to the _bind
method of the Shape
class, bind the year:change
event to the _changeYear
function. Note that this function expects that the eventArgs
object passed should contain information about the year selected in the form of its index in the YEARS
array. It's time to write the handler as follows:
_changeYear: function(currentYear) { this._updateParty(currentYear); this._shape.setOptions({ strokeColor: this._getColor({stroke: true}), fillColor: this._getColor() }); }
This method...