[GIS] Unable to display FeatureLayer using ArcGIS server

arcgis-javascript-apiarcgis-server

I can't figure out why this FeatureLayer doesn't show up on top of my base map. I'm using ArcGIS Server 10.0 and the ArcGIS JS API 2.6.

Here's the information from the service's REST parameters page:

Feature Layer: Inspection Locations (ID: 5)
Display Field: NAME
Type: Feature Layer
Geometry Type: esriGeometryPoint

Min. Scale: 250000
Max. Scale: 0

Extent: 
XMin: -8879044.1973
YMin: 4938432.3627
XMax: -7999181.0204
YMax: 5622923.0498
Spatial Reference: 102100 (3857)
.
.
.
Supported Interfaces:   REST     
Supported Operations:   Query   Add Features   Update Features   Delete Features   Apply

Edits

…and here's the code:

  <script type="text/javascript"> var djConfig = { parseOnLoad: true }; </script>
  <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.6"></script>
  <script type="text/javascript">djConfig = { parseOnLoad:true };</script>

  <script type="text/javascript">

  dojo.require("esri.map");
  dojo.require("dijit.layout.ContentPane");
  dojo.require("esri.layers.FeatureLayer");
  var map;

  function init() {

    var initExtent = new esri.geometry.Extent({
      "xmin": -8879044.1973,
      "ymin": 4938432.3627,
      "xmax": -7999181.0204,
      "ymax": 5622923.0498,
      "spatialReference": {
        "wkid": 102100
      }

    });
    map = new esri.Map("map", {extent: initExtent });

    var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");

    var featureLayer = new esri.layers.FeatureLayer("http://gis4/ArcGIS/rest/services/NY/NYeFind/FeatureServer/5",{
     mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
     outFields: ["*"]
   });

    map.addLayers([basemap, featureLayer]);

    var resizeTimer;
    dojo.connect(map, 'onLoad', function(theMap) {
      dojo.connect(dijit.byId('map'), 'resize', function() {
        clearTimeout(resizeTimer);
        resizeTimer = setTimeout(function() {
          map.resize();
          map.reposition();
        }, 500);
      });
    });

    } // end init

    dojo.addOnLoad(init);

Oddly enough, if I hit the "View in ArcGIS.com Map" link, it works perfectly.

Best Answer

I looked at your code and couldn't see anything obviously wrong with it. Have you tried sourcing an ESRI feature layer instead of your own? I have tried this with your code and it seems to work fine, there is a link to a JS fiddle below. All I have changed is the feature layer, the startup extent (so you can see the feature layer) and your resize event, because I didn't really understand why you were adding timeouts. It appears to work ok so there could be an issue with the feature layer. It would be worth identifiying that the issue is with the feature layer and not the code.

http://jsfiddle.net/dave_wilton/7pA2K/