Skip to content

Commit

Permalink
add user-defined layers
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcgee committed Apr 19, 2016
1 parent fc53a9f commit 9c97445
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions viewer/js/viewer/_MapMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,42 +60,44 @@ 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);

require(modules, lang.hitch(this, function () {
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);
Expand Down

0 comments on commit 9c97445

Please sign in to comment.