ArcGIS JS Modular Creation of Feature Layers? Possible?

Discussion created by oborden2 on Jul 19, 2013
My ultimate goal is a map which can toggle the visibility of layers on an ArcGIS map. However the data I need to use is not available as a feature service, I have to build it programatically from feature collections. I want to make AMD modules that will return FeatureLayers to a script that is in control of the map. I also want the FeatureLayers to contain events, like displaying an infoWindow or updating a dgrid onclick.

Does anyone have any advice on how to accomplish this? Can I setup the events and map markers without access to the map object? Maybe pass the map object to the FeatureLayer constructor? Any advice is greatly appreciated.

This is what I am trying. No error messages but the map doesn't display, unless I scroll the zoom in or out. Then the map displays.
require(["dojo/parser", "dojo/_base/array", "dojo/request", "dojox/layout/TableContainer", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/layout/AccordionContainer", "esri/map", "esri/layers/FeatureLayer",
             "esri/dijit/Popup", "esri/tasks/query", "dgrid/Grid", "dojo/json", "js/cbibsModule", "dojo/domReady!"],

              function (parser, array, request, TableContainer, BorderContainer, ContentPane, AccordionContainer, map, FeatureLayer, Popup, query, Grid, JSON, cbibsModule) {
                function init(){
                    _map = new map("mapDiv", {
                      basemap: "oceans",
                      center: [-77.0357, 38.7877],
                      zoom: 7
                    var cbibs = new cbibsModule();
                    var fl = cbibs.requestCBIBS(_map);

The cbibs.requestCBIBS function is supposed to not only return a feature layer but also hook up the graphics and events with the map object. Any ideas why this may not be working? Things to check? Thanks a lot!