Select to view content in your preferred language

Layer Disappears when zooming JSAPI

2108
0
12-10-2015 01:13 PM
YogiPatel
Deactivated User

So I'm learning javscript as I go along here on this web app.

I'm running into an issue when loading a geoprocessing service result as a feature layer. If the user zooms-in and out a bit, the layer disappears from the map. On the other hand, I have a feature table that shows the resulting attribute table and that information doesn't go away.

Any ideas on how I can keep the layer from disappearing? The code I'm using to add the results is below for reference.

function gp1JobComplete(jobinfo) {
            
            // Get the result map service layer and add to map.
            gp1.getResultImageLayer(jobinfo.jobId, null, null, function(layer){
              var layerURL = layer.url + "/0";
            
            var resLayer = new FeatureLayer(layerURL, {
                mode: FeatureLayer.MODE_AUTO,
                visible: true,
                id: "branches"
              });

            on(resLayer, "load", function(evt){
              console.log("Layer loaded");
              var extent = resLayer.fullExtent;
              if (webMercatorUtils.canProject(extent, map)) {
                map.setExtent( webMercatorUtils.project(extent, map) );
                }
            });

            
            if(registry.byId("myTableNode")){
              registry.byId("myTableNode").destroy();
              domConstruct.create("div", {id: "myTableNode"}, dom.byId("reports"));
              console.log("re-creating table");
            }

            var oldLayer = map.getLayer("branches");
            if(oldLayer){
            map.removeLayer(oldLayer);
            }

            map.addLayer(resLayer);

            myTable = new FeatureTable({
               "featureLayer" : resLayer,
               "map" : map
            }, 'myTableNode');

            on(myTable, "load", function(evt){
              console.log("The load event - ", evt);
            });

            myTable.startup();

            layer.id = "Bank";

            });
0 Kudos
0 Replies