Select to view content in your preferred language

webMap didLoadLayer snapshot mode

3787
5
Jump to solution
08-12-2014 12:05 PM
KyleDunaway
New Contributor III

This is the setup I have right now in an iOS app.

FeatureLayers are loaded from the webMap in didLoadLayer, and I set them to variables that I make changes to and push updates.

@property (nonatomic, strong) AGSFeatureLayer *myLayer;

- (void) webMap:(AGSWebMap *) webmap didLoadLayer:(AGSLayer *)layer

myLayer = (AGSFeatureLayer*)layer;

myLayer updateFeatures:@[featureImUpdating]

My problem is when I zoom in on a feature, the featureLayer only contains the features in the mapView, which I believe is onDemand mode?

If onDemand mode is the default for didLoadLayer, is there a way for me to change that to snapshot?

I would like to load all the features at once, instead of setting up queries.

Thanks for any help.

0 Kudos
1 Solution

Accepted Solutions
GagandeepSingh
Occasional Contributor II

Hi Kyle Dunaway‌,

There is a better way to approach this problem. When you instantiate an AGSWebMap object, the information/metadata about that web map is first loaded, which also include the `operationalLayers` property. Based on the information in the `operationalLayers` property the layers are loaded. `operationalLayers` property is an array of AGSWebMapLayerInfo objects representing each layer in the web map.

So once the web map has loaded, inside the webMapDidLoad delegate method you can run through each operationalLayer's layerInfo and change the `mode` property to `AGSFeatureLayerModeSnapshot`. Now the layers will load in the snapshot mode by default.

I believe right now you are loading each layer twice, first in OnDemand mode and then in Snapshot mode.

Let me know if you have any questions.

View solution in original post

5 Replies
KyleDunaway
New Contributor III

After webMap didLoadLayers was done, I loaded each layer I wanted in snapshot mode with

addMapLayer, and set the opacity to 0.

0 Kudos
GagandeepSingh
Occasional Contributor II

Hi Kyle Dunaway‌,

There is a better way to approach this problem. When you instantiate an AGSWebMap object, the information/metadata about that web map is first loaded, which also include the `operationalLayers` property. Based on the information in the `operationalLayers` property the layers are loaded. `operationalLayers` property is an array of AGSWebMapLayerInfo objects representing each layer in the web map.

So once the web map has loaded, inside the webMapDidLoad delegate method you can run through each operationalLayer's layerInfo and change the `mode` property to `AGSFeatureLayerModeSnapshot`. Now the layers will load in the snapshot mode by default.

I believe right now you are loading each layer twice, first in OnDemand mode and then in Snapshot mode.

Let me know if you have any questions.

KyleDunaway
New Contributor III

So something like this?

- (void) webMapDidLoad :(AGSWebMap*) webMap

{

     for(operationalLayers in webMap)

          set mode to snapshot

     [self.webMap openIntoMapView:self.mapView]

}

Not sure on the exact syntax but is that the general idea?

Thanks

EDIT:

- (void) webMapDidLoad :(AGSWebMap*) webMap

{

     for(int i = 0; i < webmap.operationalLayers.count; i++)

     {

          how to i access the layer

          webmap.operationalLayers.mode  = AGSFeatureLayerModeSnapshot

          i know this doesnt work, but something like this

     }

    [self.webMap openIntoMapView:self.mapView]

}

0 Kudos
GagandeepSingh
Occasional Contributor II

Here's a code snippet

-(void)webMapDidLoad:(AGSWebMap *)webMap {

    //change the mode on each layer

     for (AGSWebMapLayerInfo *layerInfo in layerInfoArray) {

        layerInfo.mode = AGSFeatureLayerModeSnapshot;

    }

   

    [self.webMap openIntoMapView:self.mapView];

}

0 Kudos
KyleDunaway
New Contributor III

Sweet. Thanks man.