Select to view content in your preferred language

Featurelayer.visible problem

1473
4
10-13-2011 09:04 PM
wzm
by
Emerging Contributor
hi guys, in my solution project,I use the mef(microsoft extensible framework) to dynamicly load my layers, so there is the problem:
    For the reason of efficiency ,which solution below should I take?
1:Binding a Legendlike treeview to Featurelayers,contol the loading featurelayer action by tiping the treeview checkbox;In this way, everytime we switch the visibility of the layer,actually we reload a new featurelayer,I think it works in low efficiency?
2.Like the ESRI suggests, just load all the layers at the beginning,and control every layer's visibility by Legend.
Which is better for a larger project?I suggest the second,but my boss took the first,i just want to know ,how  the visibilty property works?when it is false,it stores the data in memory?Any reply will be appreciated!!
0 Kudos
4 Replies
JenniferNery
Esri Regular Contributor
This documentation might help: http://help.arcgis.com/en/webapi/silverlight/help/index.html#//016600000015000000.htm.

FeatureLayer.Visible=False would still query the service for metadata and features. If you are concerned about the request and keeping a GraphicCollection while layer is not visible, you can maybe update your FeatureLayer.Where clause to where it will not return features or make FeatureLayer.Mode to SelectionOnly. Or you can use ArcGISDynamicMapServiceLayer if you will not be doing any editing, you can update ArcGISDynamicMapServiceLayer.VisibleLayers property instead.
0 Kudos
wzm
by
Emerging Contributor
thaks for reply,according to your advice, if user usually would change the featurelayer's visibility(Like legend does), which solution is better,loadind all the featurelayer at the very begining and leting the Legend do the rest job(just controling each layer's visibility property),or dynamiclly loading the featurelayer when setting the visibility of each layer(everytime switch the visibility,we have to rebuild the featurelayer once)? I still prefer the first, could you give me some advice?thanks very much~
0 Kudos
JenniferNery
Esri Regular Contributor
You have several options and these may not include all. I suggest you try them out and find a design that fits your need.

You can start your map with ArcGISDynamicMapServiceLayer, setting its VisibleLayers to exclude FeatureLayer's you want to turn off, when Legend control updates a sublayer visibility to true, you can create a FeatureLayer.

You can start your map with FeatureLayers Visible=False and let Legend control update each layer visibility. If the concern here is getting features before the layer is Visible, you can set FeatureLayer.Where="1 != 1" to ensure no features are returned when the layer is not visible. When layer becomes visible, FeatureLayer.Where="1=1" to query all features and call FeatureLayer.Update(). Or you can set Mode=SelectionOnly while its Visible=False and Mode=OnDemand when Visible=True, and call FeatureLayer.Update().
0 Kudos
wzm
by
Emerging Contributor
You have several options and these may not include all. I suggest you try them out and find a design that fits your need.

You can start your map with ArcGISDynamicMapServiceLayer, setting its VisibleLayers to exclude FeatureLayer's you want to turn off, when Legend control updates a sublayer visibility to true, you can create a FeatureLayer.

You can start your map with FeatureLayers Visible=False and let Legend control update each layer visibility. If the concern here is getting features before the layer is Visible, you can set FeatureLayer.Where="1 != 1" to ensure no features are returned when the layer is not visible. When layer becomes visible, FeatureLayer.Where="1=1" to query all features and call FeatureLayer.Update(). Or you can set Mode=SelectionOnly while its Visible=False and Mode=OnDemand when Visible=True, and call FeatureLayer.Update().


thanks a lot,I think I've got the point, have a nice day jenniferdnery!
0 Kudos