Skip to content

Instantly share code, notes, and snippets.

@dbouwman
Created February 24, 2013 22:42
Show Gist options
  • Save dbouwman/5026063 to your computer and use it in GitHub Desktop.
Save dbouwman/5026063 to your computer and use it in GitHub Desktop.
LayerList Controller Initialize is where all the orchestration happens because we never change the collections at runtime.
//==================================
//Controller for the LayerList Module
//==================================
var Controller = Backbone.Marionette.Controller.extend({
initialize: function (options) {
_.bindAll();
console.log('LayerListMobule:Controller:initialize');
this.region = options.region;
//The layer list has two collections
// 1) the list of basemaps
// 2) list of operational layers
this.basemapCollection = new LayerCollection(options.mapConfig.basemaps);
this.layerCollection = new LayerCollection(options.mapConfig.operationalLayers);
//create the views - these are Marionette.CollectionViews that render ItemViews
this.basemapView = new BasemapListView({collection:this.basemapCollection});
this.layersView = new LayerListView({collection:this.layerCollection});
//create our layout that will hold the child views
this.layout = new LayerListLayoutView();
//We have to render the layout before we can
//call show() on the layout's regions
this.region.show(this.layout);
this.layout.layerListRegion.show(this.layersView);
this.layout.basemapRegion.show(this.basemapView);
//hook up App events to show/hide the panel
Viewer.vent.on('View:LayerList', function (name) {
console.log('LayerListController caught View:LayerList');
$('#layer-list-region').show();
});
Viewer.vent.on('View:LayerList:Hide',function(){
$('#layer-list-region').hide();
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment