Dynamiclayer Visibility of sublayers doesn't change without movement

909
4
06-06-2011 01:39 AM
ReneNijkamp
New Contributor
Hi,

I'm using a dynamiclayer with a bunch of sublayers.
When i change the visibillity of the sublayers (through the self.dynamicLayer.visibleLayers variable) the mapview (and thereby the dynamiclayer) doesnt change. The selected or deselected objects arent (dis)appearing, not even when the dynamiclayer datachanged method is called.
Only when the map is moved the data changed (due reload of the data)...

Is this wanted behaviour? It's kinda annoying that it doesnt change on the datachanged call...

For now i implemented a work-around:    
[self.mapView zoomToEnvelope:self.mapView.envelope animated:true];


Many thanks.
0 Kudos
4 Replies
DiveshGoyal
Esri Regular Contributor
The behavior you described is not expected. Can you please share your code?
0 Kudos
ReneNijkamp
New Contributor
Of course.

First, i check if the visiblelayer array is initialised. This is done in a synchronized code block, just to be sure.

        if (self.dynamicLayer.visibleLayers == nil){
            NSLog(@"VisibleLayer is nil, initializing it.");
            NSMutableArray *visLayers = [[NSMutableArray alloc]init];
            for (AGSMapServiceLayerInfo* layer in self.dynamicLayer.mapServiceInfo.layerInfos){
                if (layer.parentLayerID != -1){
                    if (layer.defaultVisibility ){
                        [visLayers addObject:[NSNumber numberWithUnsignedInt:layer.layerId]];
                    }
                }
            }
            self.dynamicLayer.visibleLayers = [visLayers mutableCopy];
            [visLayers autorelease];
        }
    }


No problems there.

Next, when i want to change the visibillity of the layers, i use the following function:
- (void) setLayerVisibillity:(NSNumber *)layerId :(Boolean)visibillity
{
    NSMutableArray *visibleLayers = [self.dynamicLayer.visibleLayers mutableCopy];
    if (visibillity && ![visibleLayers containsObject:layerId]){
        [visibleLayers addObject:layerId];
    } else {
        [visibleLayers removeObject:layerId];
        
    }
    self.dynamicLayer.visibleLayers = [visibleLayers mutableCopy];
    [visibleLayers release];
    //Doesn't work...
    //[self.dynamicLayer dataChanged];
    //WorkAround, without the ZoomToEnvelope the layer visibillity doesnt change.
    [self.mapView zoomToEnvelope:self.mapView.envelope animated:true];
}


The ZoomToEnvelope works like a charm, but it is a extra call. DOwnside, it reloads the data from the server, which is not nice if you are working over celluar data..

More details:
IOS 4.3.3
iPad2 3G
0 Kudos
MuratDzhusupov
New Contributor II
Hi

I read some information on http://help.arcgis.com/en/arcgismobile/10.0/apis/ios/1.8/concepts/index.html#/ArcGIS_Dynamic_Map_Ser...

An ArcGIS Dynamic Map Service layer displays map content from an ArcGIS Server Map service. The Map service must not have been cached (tiled). The service generates map images when requested by the layer.


I suppose it's impossible change current image on screen without service actions (because only service generates map images).
0 Kudos
ReneNijkamp
New Contributor
Thanks. It works with this work-around. We want to cache this data, so these actions are necessary.
0 Kudos