1

I am adding a FeatureLayer in my application as follows:

featureLayer00 = new FeatureLayer("http://webadaptorserviceurl/MapServer/0",{
          mode: FeatureLayer.MODE_ONDEMAND,
      id: "0",
          outFields: ["*"],
          infoTemplate:template
        });

Then I toggle this layer with show/hide in a common.js file as follows:

...

if (visible.indexOf('0') > -1) {
            featureLayer00.show();
        }
        else {
            featureLayer00.hide();
        }
 filteronAttribute();

... It works fine until I get to filteronAttribute(). In the common.js file my filteronAttribute() loops through the layer and shows/hides each stat layer point as follows:

...
statLayer = featureLayer00.graphics;
dojo.forEach(statLayer, function (g) {
     if (sza.indexOf('all') > -1) {
         g.show();
     } else if (sza.indexOf('100') > -1 && g.attributes.hosp_beds < 100) {
         g.show();
}); ...

If the layer is on and I call filteronAttribute(), all works as expected. However, if the layer is off and I turn it on, the statLayer in filteronAttribute() is empty, even though it was just set to show.

Is there something that has to happen to the featureLayer after it is switched from hide to show before it is available in other functions?

Everything works fine if the layer is visible and I filter. However, if the filter is set and the layer is switched from show to hide, the statLayer in filteronAttribute is always empty, even though it is called after the show method on the layer. Any ideas?

1

It appears to be something with Mode_ONDEMAND.

If I use MODE_SNAPSHOT for the featureLayer it works fine.

I don't understand why MODE_ONDEMAND doesn't work in that it is visible when the function is run. If anybody has an explanation it would help.

  • 2
    I'd suggest listening to update-end event before querying. – Garima V Jan 15 '14 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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