ESRI.ArcGIS.ADF.IMS
CreateBufferSelectionLayer Method
See Also  Example
ESRI.ArcGIS.ADF.IMS.Carto.Layer Namespace > FeatureLayer Class : CreateBufferSelectionLayer Method




filter
Filter of features to be buffered.
selectionBuffer
SelectionBuffer used to select features on the target layer.
selectionRenderer
Renderer used for the selected features.
newLayerID
ID of the created buffer selection layer.
Creates a buffer selection layer based on the current FeatureLayer and a given SelectionBuffer.

Syntax

Visual Basic (Declaration) 
Public Function CreateBufferSelectionLayer( _
   ByVal filter As Filter, _
   ByVal selectionBuffer As SelectionBuffer, _
   ByVal selectionRenderer As Renderer, _
   ByVal newLayerID As String _
) As FeatureLayer
Visual Basic (Usage)Copy Code
Dim instance As FeatureLayer
Dim filter As Filter
Dim selectionBuffer As SelectionBuffer
Dim selectionRenderer As Renderer
Dim newLayerID As String
Dim value As FeatureLayer
 
value = instance.CreateBufferSelectionLayer(filter, selectionBuffer, selectionRenderer, newLayerID)
C# 
public FeatureLayer CreateBufferSelectionLayer( 
   Filter filter,
   SelectionBuffer selectionBuffer,
   Renderer selectionRenderer,
   string newLayerID
)

Parameters

filter
Filter of features to be buffered.
selectionBuffer
SelectionBuffer used to select features on the target layer.
selectionRenderer
Renderer used for the selected features.
newLayerID
ID of the created buffer selection layer.

Return Value

Created buffer selection layer.

Example

This example highlights cities with a population over one million that are within 100 kilometers of a selected river. First we get references to the source layer (rivers) and target layer (cities). Next we set up the filter for the source layer and the buffer for features that will be selected by the filter. The buffer object also specifies the target layer and an optional where expression that narrows the selected set of cities. We create a renderer for the selected cities. Finally, we create the buffer selection layer and add it to the map.

This example assumes an existing MapView object.

C#Copy Code
// Get a reference to the buffer source layer 

//  -- we will construct a buffer around features in this layer 

FeatureLayer originalLayer = 

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

  

// Get a reference to the target layer  

//  -- features in this layer will be highlighted 

FeatureLayer targetLayer =  

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

  

// Create a filter and buffer to use with the the buffer layer 

Filter layerFilter = new Filter("NAME = 'Mekong'"); 

SelectionBuffer selectionBuffer = new SelectionBuffer(); 

selectionBuffer.Distance = 100.0; 

selectionBuffer.Units = BufferUnits.Kilometers; 

selectionBuffer.WhereExpression = "POPULATION > 1000000"; 

selectionBuffer.TargetLayer = targetLayer; 

  

// Create the renderer to display the selected features in the target layer 

SimpleMarkerSymbol bufferSelSymbol =  

    new SimpleMarkerSymbol(System.Drawing.Color.Cyan,  

    16, MarkerSymbolType.Star); 

SimpleRenderer bufferSelectionRenderer =  

    new SimpleRenderer(bufferSelSymbol); 

  

// Create the buffer selection layer 

FeatureLayer bufferSelectionLayer = 

    originalLayer.CreateBufferSelectionLayer(layerFilter, 

    selectionBuffer, bufferSelectionRenderer, "CitiesSelectedByBuffer"); 

  

// Add the buffer selection layer to the map 

mapView.Layers.Add(bufferSelectionLayer); 

Image1.ImageUrl = mapView.Draw().Url 

    
Visual BasicCopy Code
' Get a reference to the buffer source layer

' -- will will construct a buffer around features in this layer

Dim originalLayer As FeatureLayer = _

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



' Get a reference to the target layer

' -- features in this layer will be highlighted

Dim targetLayer As FeatureLayer = _

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



' Create a filter and buffer to use with the the buffer layer

Dim layerFilter As New Filter("NAME = 'Mekong'")

Dim selectionBuffer As New SelectionBuffer()

selectionBuffer.Distance = 100.0

selectionBuffer.Units = BufferUnits.Kilometers

selectionBuffer.WhereExpression = "POPULATION > 1000000"

selectionBuffer.TargetLayer = targetLayer



' Create the renderer to display the selected features in the target layer

Dim bufferSelSymbol As _

    New SimpleMarkerSymbol(System.Drawing.Color.Cyan, _

    16, MarkerSymbolType.Star)

Dim bufferSelectionRenderer As _

    New SimpleRenderer(bufferSelSymbol)



' Create the buffer selection layer

Dim bufferSelectionLayer As FeatureLayer = _

    originalLayer.CreateBufferSelectionLayer(layerFilter, _

    selectionBuffer, bufferSelectionRenderer, "CitiesSelectedByBuffer")



' Add the buffer selection layer to the map

mapView.Layers.Add(bufferSelectionLayer)

Image1.ImageUrl = mapView.Draw().Url

Remarks

This method selects and highlights features that fall within a buffer. The buffer is created by selecting features in the current feature layer using the filter parameter, and constructing a buffer around those features using the selectionBuffer parameter. The selection buffer object also specifies which layer to select from with the buffer. This layer is also known as the "target" layer for the buffer.

If you need to display the buffer itself, use CreateBufferLayer. A map can show both buffer and buffer selection layers. If you need to retrieve information about features found within a buffer, use Query(QueryParameters). If you need to select features by buffering around an arbitrary geometry object, use CreateSelectionLayer(Filter, Renderer, string), and set a Tolerance and Geometry for the Filter object.

Known limit: when using ArcMap Server image services, the FeatureLayer cannot be the same as the target layer for the buffer defined in SelectionBuffer.TargetLayer. If you need to buffer from and to the same data source, a workaround is to create two layers from the data source in the ArcMap document, and use the copy as the target layer.

The filter defines which features to buffer from. The buffer is drawn around these features. If no features are found with the filter, then no buffer will be created and therefore no features will be found and highlighted.

To display the features selected with the buffer, typically a SimpleRenderer is used for the renderer.

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

If used with ArcMap image services, the layer's Renderer must be set to null before drawing the map. Renderers cannot be used in selection or buffer layers for ArcMap image services. If a renderer is used, an error will be thrown. As an alternative, use the FeatureLayer(FeatureLayer) to construct a copy of the layer, then set the Filter, Buffer and ID of the new layer before adding it to the map's layer collection.

See Also

© 2010 All Rights Reserved.