When the server returns the view to the browser, our Router module shows it on the page:
_showRoute: function (result) { this._container.html(result); this._map.entities.clear(); this._showRouteLine(); this._showPins(); }
First, we replace the container inner HTML with the View, and then we show the route line and pins:
_showRouteLine: function () { var locations = this._parseLocations('lbm-router-route-path'), options = {}; if (locations.length) { var polyline = new Microsoft.Maps.Polyline(locations); this._map.entities.push(polyline); options = { bounds: Microsoft.Maps.LocationRect.fromLocations(locations) }; } else { options = { center: this._initialCenter, zoom: this._initialZoom }; } this._map.setView(options); }
For the sake of simplicity, we transfer the coordinates of the locations inside the view, when normally we would use other data exchange methods, such as JSON or XML.
_parseLocations: function...