several ways to control the visible state of features in a layer from the original AE
There are often such needs in the work, a job layer by several operators to operate, we have to control each operator can only see the area he is responsible for. The visible area control of the operator is sometimes divided by the space area, sometimes according to the assignment attribute, sometimes the attribute and the region combine to divide, how should control in the program ? I have summed up the following several methods available, I do not know whether we have a better solution.
? unique value notation method
This method is simple by setting a unique value symbol rendering to the layer, and setting the feature symbol that you don't want to display to null. Although simple, this method has great limitations, if we want to control the feature visible state of an area, this method cannot be implemented. This method is only applicable to control the visible state of features by job properties.
? ifeaturelayerdefinition
There are two ways that the interface can control the visible state of a feature.
Method One:
With the Definitionexpression method of the interface, you can set a query condition for the layer, and only the layers that match the query criteria will be displayed. For example: We just want to show the features in the layer with the Name attribute ' Beijing ', then the code is as follows:
ILayer pLayer = axMapControl1. Get_layer (0);
Ifeaturelayerdefinition pfldefinition = pLayer as ifeaturelayerdefinition;
Pfldefinition. definitionexpression = "Name = ' Beijing '";
This party is used to control the visible state of features according to the job properties.
Method Two:
The Createselectionlayer method allows you to generate a new layer of selected features in the current layer, and only the selected features of the original layer in the resulting new layer are visible. This method can be used to control the display of features within a space range only. The downside is that if we add features to the space, the new additions are not displayed.
This party is used to control the visible state of features according to the scope of the job space.
? Igeofeaturelayer
The exclusionset of the Igeofeaturelayer interface allows you to exclude some of the features in the layer from being invisible. The Exclusionset property controls which features are excluded from the display through the Ifeatureidset interface, for example, we want to control that features with FID 2, 5, and 8 do not display. Can be implemented with the following code:
ILayer PLayer = axMapControl1. Get_layer (0asnew Featureidsetclass ( );p IDSet. ADD (2);p IDSet. ADD (5);p IDSet. ADD (8= Pidset;
This method is more flexible and can be used to control the visible features precisely, the disadvantage is that it cannot be saved to the MXD and can only be controlled dynamically while the program is running.
Several methods for AE to control the visible state of features in a layer