The approach we have taken throughout this book is to extend the Microsoft.Maps API by means of modules. This project is not an exception. So far, our project folder holds the index.html
file and the learningTheme
folder. Let's add a poll
directory, inside which we create the poll.js
and poll.css
files.
Let's start with our familiar module skeleton inside poll.js,
as shown in the following code snippet:
(function() { var lbm = window.lbm || {}; lbm.Poll = function(map, $) { this._map = map; this.$ = $; }; Microsoft.Maps.moduleLoaded('lbm.Poll'); })();
The Poll
module is attached to the lbm
namespace so that the global scope does not get cluttered. Its constructor accepts an instance of the map and a jQuery
object as its arguments.
Now it's time to pause for a minute and think how we want to develop the user interface. The requirements state that we need to show the results for four elections; so probably a list with four buttons labeled with each elections year could...