As we have done previously, we will organize our client side inside a Microsoft Maps module, which we will name geodata.js
.
(function () { var lbm = window.lbm || {}; lbm.Geodata = function (map, $) { this._map = map; this.$ = $; }; Microsoft.Maps.moduleLoaded('lbm.Geodata'); })();
Next, we create a stylesheet file, geodata.css
, inside the Content
folder, and add a link to it in our module, as we did in the previous chapter.
_addCss: function () { var link = document.createElement('link'); link.setAttribute('rel', 'stylesheet'); link.setAttribute('href', '/Content/geodata.css'); var head = document.getElementsByTagName('head')[0]; head.appendChild(link); }
We would like our app to respond to user clicks, so we add a handler for that event:
_bind: function (self) { Microsoft.Maps.Events.addHandler(this._map, 'click', function (e) { if (e.originalEvent.target.tagName !== 'BUTTON') { self._onclick(e); ...