ESRI.ArcGIS.ADF.IMS
CreateSelectionLayer(Point,Double,Renderer,String) Method
See Also  Example
ESRI.ArcGIS.ADF.IMS.Carto.Layer Namespace > FeatureLayer Class > CreateSelectionLayer Method : CreateSelectionLayer(Point,Double,Renderer,String) Method




point
Point location for selecting features.
expandPercentage
Percentage-based tolerance to determine the size of the envelope created around the map-point.
selectionRenderer
Renderer of the selection layer to be created.
newLayerID
ID of the selection layer to be created.
Creates a selection layer based on the current FeatureLayer, and selects the features near a given point.

Syntax

Visual Basic (Declaration) 
Public Overloads Function CreateSelectionLayer( _
   ByVal point As Point, _
   ByVal expandPercentage As Double, _
   ByVal selectionRenderer As Renderer, _
   ByVal newLayerID As String _
) As FeatureLayer
Visual Basic (Usage)Copy Code
Dim instance As FeatureLayer
Dim point As Point
Dim expandPercentage As Double
Dim selectionRenderer As Renderer
Dim newLayerID As String
Dim value As FeatureLayer
 
value = instance.CreateSelectionLayer(point, expandPercentage, selectionRenderer, newLayerID)
C# 
public FeatureLayer CreateSelectionLayer( 
   Point point,
   double expandPercentage,
   Renderer selectionRenderer,
   string newLayerID
)

Parameters

point
Point location for selecting features.
expandPercentage
Percentage-based tolerance to determine the size of the envelope created around the map-point.
selectionRenderer
Renderer of the selection layer to be created.
newLayerID
ID of the selection layer to be created.

Return Value

Created selection layer.

Example

The following example selects countries near a point, and highlights them on the map. A point is defined as the center of selection, and an expand percentage is defined. A renderer with symbol is created to highlight the point features. The selection layer is created with point, expandPercentage and renderer, and is added to the map. The example assumes an existing MapView object.
C#Copy Code
// Get a reference to the layer 

FeatureLayer originalLayer = 

    (FeatureLayer)mapView.Layers.FindByName("Countries"); 

  

// Create geometry for the selection 

ESRI.ArcGIS.ADF.IMS.Geometry.Point selectionPoint =  

    new ESRI.ArcGIS.ADF.IMS.Geometry.Point(25, 45); 

double bufferPercentage = 1.0; 

  

// Create a renderer for the selected features 

SimpleFillSymbol selSymbol =  

    new SimpleFillSymbol(System.Drawing.Color.Red,  

    System.Drawing.Color.Red, PolygonFillType.FDiagonal); 

SimpleRenderer selRenderer = new SimpleRenderer(selSymbol); 

  

// Create the selection layer and add it to the map 

FeatureLayer selectionLayer = 

    originalLayer.CreateSelectionLayer(selectionPoint,  

    bufferPercentage, selRenderer, "SelectedCountry"); 

mapView.Layers.Add(selectionLayer); 

Image1.ImageUrl = mapView.Draw().Url; 

    
Visual BasicCopy Code
' Get a reference to the layer

Dim originalLayer As FeatureLayer = _

    CType(mapView.Layers.FindByName("Countries"), FeatureLayer)



' Create geometry for the selection

Dim selectionPoint As New ESRI.ArcGIS.ADF.IMS.Geometry.Point(25, 45)

Dim bufferPercentage As Double = 1.0



' Create a renderer for the selected features

Dim selSymbol As New SimpleFillSymbol(System.Drawing.Color.Red,

    System.Drawing.Color.Red, PolygonFillType.FDiagonal);

Dim selRenderer As New SimpleRenderer(selSymbol)



' Create the selection layer and add it to the map

Dim selectionLayer As FeatureLayer = _

    originalLayer.CreateSelectionLayer(selectionPoint, _

    bufferPercentage, selRenderer, "SelectedCountry")

mapView.Layers.Add(selectionLayer)

Image1.ImageUrl = mapView.Draw().Url

Remarks

This method creates a layer that highlights features from an existing layer. It selects features using an envelope surrounding the input Point object. The envelope is sized based on a percentage of the current map extent. The expandPercentage parameter determines this percentage. The percentage must be greater than zero, and less than or equal to 100.

A renderer must be assigned to the layer for map display. The renderer's symbol must be appropriate to the source layer. For example, if a point layer is used for the selection, then a symbol derived from MarkerSymbol must be used for rendering.

The selection layer ID must be unique among all layers in the collection. The ID can be any combination of alpha and numeric characters.

This method is not recommended for ArcMap image services. Renderers cannot be used in selection layers for ArcMap image services. If a renderer is used, an error will be thrown. A workaround with this method is to set the renderer to null after using this method. As an alternative, use the FeatureLayer(FeatureLayer) to construct a copy of the layer, then set the Filter and ID of the new layer before adding it to the map's layer collection.

See Also

© 2010 All Rights Reserved.