Skip to content

Commit

Permalink
use createMap method to allow mixins to modify map before resolving d…
Browse files Browse the repository at this point in the history
…eferred
  • Loading branch information
green3g committed Jan 20, 2017
1 parent 7cb59c3 commit 6f319d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 15 additions & 3 deletions viewer/js/viewer/_MapMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,31 @@ define([
var returnDeferred = new Deferred();
var returnWarnings = [];

this._createMap(returnWarnings).then(
this.createMap(returnWarnings).then(
lang.hitch(this, '_createMapResult', returnDeferred, returnWarnings)
);
returnDeferred.then(lang.hitch(this, 'initMapComplete'));
return returnDeferred;
},

_createMap: function (returnWarnings) {
createMap: function (returnWarnings) {
var returnWarnings = [];
var mapDeferred = new Deferred(),
container = dom.byId(this.config.layout.map) || 'mapCenter';

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

// let some other mixins modify or add map items async
var wait = this.inherited(arguments);
if (wait) {
wait.then(function (warnings) {
// are warnings passed?
// returnWarnings.push(warnings);
mapDeferred.resolve(returnWarnings);
});
} else {
mapDeferred.resolve(returnWarnings);
}
return mapDeferred;
},

Expand Down
4 changes: 2 additions & 2 deletions viewer/js/viewer/_WebMapMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ define([
return declare(null, {
startup: function () {
this.inherited(arguments);
this.mapDeferred.then(lang.hitch(this, '_initWebMap'));
// this.mapDeferred.then(lang.hitch(this, '_initWebMap'));
},

_initWebMap: function () {
createMap: function () {
var webMapOptions = this.config.webMapOptions || {};
if (!webMapOptions.mapOptions && this.config.mapOptions) {
webMapOptions.mapOptions = this.config.mapOptions;
Expand Down

0 comments on commit 6f319d7

Please sign in to comment.