Now, let's add a basic ASP.NET MVC
project to our VS solution named LBM.Geocoder.Web
. The website is very similar to the one we built in the previous chapter, so we can copy HomeController.cs
, _Layout.cshtml
, the Index.chtml
views, app.js
, app.css
, learningTheme
, and BundleConfig.cs
from it.
Next, we create a new JavaScript module, geocoder.js
, and save it inside the Scripts
folder:
lbm.Geocoder = function(map, $) { this._map = map; this.$ = $; this._addCss(); }; lbm.Geocoder.prototype = { _addCss: function () { var link = document.createElement('link'); link.setAttribute('rel', 'stylesheet'); link.setAttribute('href', '/Content/geocoder.css'); var head = document.getElementsByTagName('head')[0]; head.appendChild(link); } }; Microsoft.Maps.moduleLoaded('lbm.Geocoder');
We also pass a $
argument to the module, in the shape of an object that will perform AJAX requests (in our case jQuery
), using the good practice of dependency...