O'Reilly logo

Learning Bing Maps API by Artan Sinani

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The shape

As we saw earlier, this class stores a reference to the map, data, and the initial year. The election results of the latter will be reflected on the shape first, as shown in the following code snippet:

var Shape = function (map, data, currentYear) {
  this._map = map;
  this._data = data;
  this._updateParty(currentYear);
}

A shape will be filled with the color of the political party that has won the elections on the London Assembly area represented by that shape. For this, we create an object instance variable (_party) with the id extracted from the votes array.

_updateParty: function(year) {
  this._party = {
    id: this._data.votes[year]
  };
  this._party.name = PARTIES[this._party.id];
}

The party's name is fetched from a constant array we define ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required