Skip to content

Commit

Permalink
override createMap method if mixin returns a deferred
Browse files Browse the repository at this point in the history
 - as a result, order is not important with map/webmap mixins
  • Loading branch information
green3g committed Jan 20, 2017
1 parent 6f319d7 commit 76ef0db
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion viewer/js/config/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
) {
var App = declare([
_LayoutMixin,
_MapMixin,
_WidgetsMixin,

_WebMapMixin,
_MapMixin,
_ConfigMixin,
_ControllerBase
]);
Expand Down
10 changes: 9 additions & 1 deletion viewer/js/viewer/_MapMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,22 @@ define([
},

createMap: function (returnWarnings) {

// mixins override the default createMap method and return a deferred
var result = this.inherited(arguments);
if (result) {
return result;
}

// otherwise we can create the map
var returnWarnings = [];
var mapDeferred = new Deferred(),
container = dom.byId(this.config.layout.map) || 'mapCenter';

this.map = new Map(container, this.config.mapOptions);

// let some other mixins modify or add map items async
var wait = this.inherited(arguments);
wait = this.inherited(arguments) || wait;
if (wait) {
wait.then(function (warnings) {
// are warnings passed?
Expand Down
1 change: 1 addition & 0 deletions viewer/js/viewer/_WebMapMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ define([
},

createMap: function () {
console.log('web map mixin');
var webMapOptions = this.config.webMapOptions || {};
if (!webMapOptions.mapOptions && this.config.mapOptions) {
webMapOptions.mapOptions = this.config.mapOptions;
Expand Down

0 comments on commit 76ef0db

Please sign in to comment.