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




geometry
Features that intersect this geometry will be selected.
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 that intersect a given geometry.

Syntax

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

Parameters

geometry
Features that intersect this geometry will be selected.
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 cities within an envelope and highlights them on the map. An envelope is created as the selection geometry, and a renderer with symbol is created to highlight the point features. The selection layer is created with the geometry 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("Cities"); 

  

// Create geometry for the selection 

Envelope selectionGeometry = new Envelope(20, 40, 25, 45); 

  

// Create a renderer for the selected features 

SimpleMarkerSymbol selSymbol = new SimpleMarkerSymbol(System.Drawing.Color.Red, 16); 

SimpleRenderer selRenderer = new SimpleRenderer(selSymbol); 

  

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

FeatureLayer selectionLayer = 

    originalLayer.CreateSelectionLayer(selectionGeometry, selRenderer, "SelectedCities"); 

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("Cities"), FeatureLayer)



' Create geometry for the selection

Dim selectionGeometry As New Envelope(20, 40, 25, 45)



' Create a renderer For the selected features

Dim selSymbol As New SimpleMarkerSymbol(System.Drawing.Color.Red, 16)

Dim selRenderer As New SimpleRenderer(selSymbol)



' Create the selection layer And add it To the map

Dim selectionLayer As FeatureLayer = _

    originalLayer.CreateSelectionLayer(selectionGeometry, selRenderer, "SelectedCities")

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 a Geometry object. The geometry can be an Envelope, Point, Polyline, or Polygon.

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.