Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
    
what does fiddler tell u when u hit the app? –  Simon Dec 19 '12 at 12:33
    
I am also researching your issue..Try to copy esri sample then modify that sample (enter your feature layer). I think it will help you. –  Sunil Dec 19 '12 at 13:19
add comment

2 Answers

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/

share|improve this answer
1  
@ David I agree with you.. –  Sunil Dec 19 '12 at 13:19
add comment

For whatever reason, once I cleared my Chrome cache, it worked correctly.

Why the layer wouldn't load because it was in the cache, I still don't know.

share|improve this answer
    
It is more likely that the page with your javascript code was being cached, so changes you made to fix the issue weren't picked up until the cache was cleared. –  mwalker Dec 19 '12 at 21:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.