Georgie.Cassar

Zoom to extent of graphic array in Feature Layer not working

Discussion created by Georgie.Cassar on Jun 30, 2011
Latest reply on Dec 16, 2012 by hunterwei
I can't work out why my map is not zooming to the extent of graphics in my featurelayer.

See at the bottom of this code where I try and use the esri.graphicextent method.

function initOperationalLayer(map) {
        var content = "<b>Street: </b>${Street_Name}, ${Suburb}<br/>"
                             + "<b>Pickup Time: </b>${Departure_Time}";

        var infoTemplate = new esri.InfoTemplate("Route 1 Details", content);

        var featureLayer = new esri.layers.FeatureLayer("http://gsportenf/ArcGIS/rest/services/Public_Access/MapServer/12",{
          mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
          outFields: ["*"],
          infoTemplate: infoTemplate
        });


        map.addLayer(featureLayer);
        var symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,255,255,0.35]), 1);
        var renderer = new esri.renderer.SimpleRenderer(symbol);
        featureLayer.setRenderer(renderer);
        map.infoWindow.resize(300,100);
        var zoomExtent= esri.graphicsExtent(featureLayer.graphics);
        map.setExtent(zoomExtent);    // THE MAP IS NOT CHANGING !!!
  }

Outcomes