diff --git a/viewer/js/config/viewer.js b/viewer/js/config/viewer.js index 9569a7007..39b0194b2 100644 --- a/viewer/js/config/viewer.js +++ b/viewer/js/config/viewer.js @@ -53,6 +53,7 @@ define([ zoom: 5, sliderStyle: 'small' }, + // panes: { // left: { // splitter: true @@ -81,6 +82,29 @@ define([ // }, // collapseButtonsPane: 'center', //center or outer + // custom titles + /* + titles: { + header: 'My App', + subHeader: 'My GIS App is the best!', + pageTitle: 'My App' + }, + */ + + // user-defined layer types + /* + layerTypes: { + myCustomLayer: 'widgets/MyCustomLayer' + }, + */ + + // user-defined widget types + /* + widgetTypes: [ + 'myWidgetType' + ], + */ + // operationalLayers: Array of Layers to load on top of the basemap: valid 'type' options: 'dynamic', 'tiled', 'feature'. // The 'options' object is passed as the layers options for constructor. Title will be used in the legend only. id's must be unique and have no spaces. // 3 'mode' options: MODE_SNAPSHOT = 0, MODE_ONDEMAND = 1, MODE_SELECTION = 2 diff --git a/viewer/js/gis/dijit/LayerControl.js b/viewer/js/gis/dijit/LayerControl.js index a47cb8c5b..c1158b1f0 100644 --- a/viewer/js/gis/dijit/LayerControl.js +++ b/viewer/js/gis/dijit/LayerControl.js @@ -85,6 +85,8 @@ define([ }); return; } + // add any user-defined controls - possibly for user-defined layers + this._controls = lang.mixin(this._controls, options.controls || {}); }, postCreate: function () { this.inherited(arguments); diff --git a/viewer/js/viewer/_MapMixin.js b/viewer/js/viewer/_MapMixin.js index 57cd22244..4806d7e75 100644 --- a/viewer/js/viewer/_MapMixin.js +++ b/viewer/js/viewer/_MapMixin.js @@ -60,34 +60,36 @@ define([ _initLayers: function (returnWarnings) { this.layers = []; var layerTypes = { - csv: 'CSV', - dataadapter: 'DataAdapterFeature', //untested - dynamic: 'ArcGISDynamicMapService', - feature: 'Feature', - georss: 'GeoRSS', - image: 'ArcGISImageService', - imagevector: 'ArcGISImageServiceVector', - kml: 'KML', - label: 'Label', //untested - mapimage: 'MapImage', //untested - osm: 'OpenStreetMap', - raster: 'Raster', - stream: 'Stream', - tiled: 'ArcGISTiledMapService', - vectortile: 'VectorTile', - webtiled: 'WebTiled', - wfs: 'WFS', - wms: 'WMS', - wmts: 'WMTS' //untested + csv: 'esri/layers/CSVLayer', + dataadapter: 'esri/layers/DataAdapterFeatureLayer', //untested + dynamic: 'esri/layers/ArcGISDynamicMapServiceLayer', + feature: 'esri/layers/FeatureLayer', + georss: 'esri/layers/GeoRSSLayer', + image: 'esri/layers/ArcGISImageServiceLayer', + imagevector: 'esri/layers/ArcGISImageServiceVectorLayer', + kml: 'esri/layers/KMLLayer', + label: 'esri/layers/LabelLayer', //untested + mapimage: 'esri/layers/MapImageLayer', //untested + osm: 'esri/layers/OpenStreetMapLayer', + raster: 'esri/layers/RasterLayer', + stream: 'esri/layers/StreamLayer', + tiled: 'esri/layers/ArcGISTiledMapServiceLayer', + vectortile: 'esri/layers/VectorTileLayer', + webtiled: 'esri/layers/WebTiledLayer', + wfs: 'esri/layers/WFSLayer', + wms: 'esri/layers/WMSLayer', + wmts: 'esri/layers/WMTSLayer' //untested }; + // add any user-defined layer types such as https://github.com/Esri/geojson-layer-js + layerTypes = lang.mixin(layerTypes, this.config.layerTypes || {}); // loading all the required modules first ensures the layer order is maintained var modules = []; array.forEach(this.config.operationalLayers, function (layer) { var type = layerTypes[layer.type]; if (type) { - modules.push('esri/layers/' + type + 'Layer'); + modules.push(type); } else { - returnWarnings.push('Layer type "' + layer.type + '"" isnot supported: '); + returnWarnings.push('Layer type "' + layer.type + '" is not supported: '); } }, this); @@ -95,7 +97,7 @@ define([ array.forEach(this.config.operationalLayers, function (layer) { var type = layerTypes[layer.type]; if (type) { - require(['esri/layers/' + type + 'Layer'], lang.hitch(this, '_initLayer', layer)); + require([type], lang.hitch(this, '_initLayer', layer)); } }, this); this.map.addLayers(this.layers); diff --git a/viewer/js/viewer/_WidgetsMixin.js b/viewer/js/viewer/_WidgetsMixin.js index 78dc52f41..22624d9a3 100644 --- a/viewer/js/viewer/_WidgetsMixin.js +++ b/viewer/js/viewer/_WidgetsMixin.js @@ -79,8 +79,10 @@ define([ widgetLoader: function (widgetConfig, position) { var parentId, pnl; - // only proceed for valid widget types var widgetTypes = ['titlePane', 'contentPane', 'floating', 'domNode', 'invisible', 'map']; + // add any user-defined widget types + widgetTypes = widgetTypes.concat(this.config.widgetTypes || []); + // only proceed for valid widget types if (array.indexOf(widgetTypes, widgetConfig.type) < 0) { this.handleError({ source: 'Controller',