From 9c97445bba7658182577475d968b77dafd52c79c Mon Sep 17 00:00:00 2001 From: Tim McGee Date: Tue, 19 Apr 2016 16:14:37 -0700 Subject: [PATCH 1/4] add user-defined layers --- viewer/js/viewer/_MapMixin.js | 46 ++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 22 deletions(-) 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); From b9b367a678f423ed0ecb2b531c37a4d63e76ec05 Mon Sep 17 00:00:00 2001 From: Tim McGee Date: Tue, 19 Apr 2016 16:14:55 -0700 Subject: [PATCH 2/4] add user-defined widgets --- viewer/js/viewer/_WidgetsMixin.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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', From 357d924ff1a5c04dedf531c83c592778a6120b73 Mon Sep 17 00:00:00 2001 From: Tim McGee Date: Tue, 19 Apr 2016 16:15:23 -0700 Subject: [PATCH 3/4] add user-defined controls for layerControl widget --- viewer/js/gis/dijit/LayerControl.js | 2 ++ 1 file changed, 2 insertions(+) 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); From 3bba918626859950fbde5fa8a7fa7389ff33b9e9 Mon Sep 17 00:00:00 2001 From: Tim McGee Date: Tue, 19 Apr 2016 16:15:58 -0700 Subject: [PATCH 4/4] add examples of custom titles, layerTypes and widgetTypes --- viewer/js/config/viewer.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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