I want to change mode from MODE_SNAPSHOP to MODE_ONDEMAND at runtime

3474
1
03-18-2015 12:51 PM
Lars_HalvorAnundskaas
New Contributor III

I have a featurelayer in my map, added with MODE_SNAPSHOT, so that all features are showing.

I want the user to be able to switch to MODE_ONDEMAND, the behavior i want is that the layer will be redrawn with only the features within the screen.

It works as expected when i add it to the map in the first place, with either MODE_ONDEMAND or MODE_SNAPSHOT, but I havent figured out how I can change it at runtime, after it has been added to the map.

This does not work:

featureLayerInstance.mode = FeatureLayer.MODE_ONDEMAND;

featureLayerInstance.refresh();

Looking at the requests, geometry are not added and removed to the parameters to the request when toggling mode at runtime, like it does when i add the layer with MODE_ONDEMAND in the first place.

Ideally I would like it to automatically do a geometry query with MODE_ONDEMAND, and a "1=1" query with MODE_SNAPSHOT

Does anyone know how i can achieve this at runtime without removing and readding the layer etc.?

0 Kudos
1 Reply
AnthonyGiles
Frequent Contributor

Lars,

have you tried DEMAND_AUTO:

FeatureLayer | API Reference | ArcGIS API for JavaScript

Regards

Anthony​