Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for webmaps #626

Merged
merged 2 commits into from
Nov 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions viewer/js/config/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@
'viewer/_ConfigMixin', // manage the Configuration
'viewer/_LayoutMixin', // build and manage the Page Layout and User Interface
'viewer/_MapMixin', // build and manage the Map
'viewer/_WidgetsMixin' // build and manage the Widgets
'viewer/_WidgetsMixin', // build and manage the Widgets

'viewer/_WebMapMixin' // for WebMaps
//'config/_customMixin'

], function (
Expand All @@ -50,8 +51,9 @@
_ConfigMixin,
_LayoutMixin,
_MapMixin,
_WidgetsMixin
_WidgetsMixin,

_WebMapMixin
//_MyCustomMixin

) {
Expand All @@ -60,7 +62,9 @@
_ConfigMixin,
_LayoutMixin,
_MapMixin,
_WidgetsMixin
_WidgetsMixin,

_WebMapMixin
]))();
controller.startup();
});
Expand Down
13 changes: 4 additions & 9 deletions viewer/js/config/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ define([
sliderStyle: 'small'
},

//webMapId: 'ef9c7fbda731474d98647bebb4b33c20', // High Cost Mortgage
// webMapOptions: {},

// panes: {
// left: {
// splitter: true
Expand Down Expand Up @@ -278,7 +281,7 @@ define([
srcNodeRef: 'growlerDijit',
options: {}
},
geocoder: {
search: {
include: true,
type: 'domNode',
path: 'esri/dijit/Search',
Expand All @@ -301,14 +304,6 @@ define([
position: 3,
options: 'config/identify'
},
basemaps: {
include: true,
id: 'basemaps',
type: 'domNode',
path: 'gis/dijit/Basemaps',
srcNodeRef: 'basemapsDijit',
options: 'config/basemaps'
},
mapInfo: {
include: false,
id: 'mapInfo',
Expand Down
20 changes: 20 additions & 0 deletions viewer/js/viewer/_ControllerBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ define([
// add growler here?
return;
}
},

mixinDeep: function (dest, source) {
//Recursively mix the properties of two objects
var empty = {};
for (var name in source) {
if (!(name in dest) || (dest[name] !== source[name] && (!(name in empty) || empty[name] !== source[name]))) {
try {
if (source[name].constructor === Object) {
dest[name] = this.mixinDeep(dest[name], source[name]);
} else {
dest[name] = source[name];
}
} catch (e) {
// Property in destination object not set. Create it and set its value.
dest[name] = source[name];
}
}
}
return dest;
}
});
});
67 changes: 46 additions & 21 deletions viewer/js/viewer/_MapMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,49 @@ define([
var returnDeferred = new Deferred();
var returnWarnings = [];

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

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

if (this.config.mapOptions.basemap) {
this.map.on('load', lang.hitch(this, '_initLayers', returnWarnings));
if (this.config.webMapId) {
if (this._initWebMap) {
mapDeferred = this._initWebMap(this.config.webMapId, container, this.config.webMapOptions);
} else {
returnWarnings.push('The "_WebMapMixin" Controller Mixin is required to use a webmap');
mapDeferred.resolve(returnWarnings);
}
} else {
this._initLayers(returnWarnings);
this.map = new Map(container, this.config.mapOptions);
mapDeferred.resolve(returnWarnings);
}
return mapDeferred;
},

_createMapResult: function (returnDeferred, returnWarnings) {
if (this.map) {
if (!this.config.webMapId && this.config.mapOptions && this.config.mapOptions.basemap) {
this.map.on('load', lang.hitch(this, '_initLayers', returnWarnings));
} else {
this._initLayers(returnWarnings);
}

if (this.config.operationalLayers && this.config.operationalLayers.length > 0) {
on.once(this.map, 'layers-add-result', lang.hitch(this, '_onLayersAddResult', returnDeferred, returnWarnings));
if (this.config.operationalLayers && this.config.operationalLayers.length > 0) {
on.once(this.map, 'layers-add-result', lang.hitch(this, '_onLayersAddResult', returnDeferred, returnWarnings));
} else {
returnDeferred.resolve(returnWarnings);
}
} else {
returnDeferred.resolve(returnWarnings);
}
return returnDeferred;
},

_createMap: function () {
var container = dom.byId(this.config.layout.map) || 'mapCenter';
this.map = new Map(container, this.config.mapOptions);
},

_onLayersAddResult: function (returnDeferred, returnWarnings, lyrsResult) {
array.forEach(lyrsResult.layers, function (addedLayer) {
if (addedLayer.success !== true) {
Expand Down Expand Up @@ -171,18 +193,21 @@ define([
});
}

this.map.on('resize', function (evt) {
var pnt = evt.target.extent.getCenter();
setTimeout(function () {
evt.target.centerAt(pnt);
}, 100);
});
if (this.map) {
this.map.on('resize', function (evt) {
var pnt = evt.target.extent.getCenter();
setTimeout(function () {
evt.target.centerAt(pnt);
}, 100);
});

// in _LayoutsMixin
this.createPanes();
// in _LayoutsMixin
this.createPanes();

// in _WidgetsMixin
this.initWidgets();
}

// in _WidgetsMixin
this.initWidgets();
},

initMapError: function (err) {
Expand Down
Loading