5

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.

2
  • what does fiddler tell u when u hit the app?
    – jakc
    Commented Dec 19, 2012 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
    Commented Dec 19, 2012 at 13:19

2 Answers 2

4

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/

1
  • 1
    @ David I agree with you..
    – Sunil
    Commented Dec 19, 2012 at 13:19
0

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.

1
  • 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
    Commented Dec 19, 2012 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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