Creates a selection layer based on the current FeatureLayer and a given Filter.
Syntax
Visual Basic (Usage) | Copy Code |
---|
Dim instance As FeatureLayer
Dim filter As Filter
Dim selectionRenderer As Renderer
Dim newLayerID As String
Dim value As FeatureLayer
value = instance.CreateSelectionLayer(filter, selectionRenderer, newLayerID) |
Parameters
- filter
- Filter of the selection layer to be created.
- 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 and highlights the cities within 500 kilometers of a specified envelope. It creates a filter with the envelope and a buffer tolerance of 500 kilometers. It creates a renderer for the selected cities. Finally, it creates the selection layer with the filter and renderer and adds it to the map. This examples assumes as existing MapView object.
C# | Copy Code |
---|
// Get a reference to the layer
FeatureLayer originalLayer =
(FeatureLayer)mapView.Layers.FindByName("Cities");
// Create filter for the selection
Filter selFilter = new Filter();
selFilter.Geometry = new Envelope(25, 35, 28, 38);
selFilter.Tolerance = 500.0;
selFilter.ToleranceUnits = BufferUnits.Kilometers;
// 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(selFilter, selRenderer, "SelectedCities");
mapView.Layers.Add(selectionLayer);
Image1.ImageUrl = mapView.Draw().Url; |
Visual Basic | Copy Code |
---|
' Get a reference To the layer
Dim originalLayer As FeatureLayer = _
CType(mapView.Layers.FindByName("Cities"), FeatureLayer)
' Create filter For the selection
Dim selFilter As New Filter()
selFilter.Geometry = New Envelope(25, 35, 28, 38)
selFilter.Tolerance = 500.0
selFilter.ToleranceUnits = BufferUnits.Kilometers
' 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(selFilter, selRenderer, "SelectedCities")
mapView.Layers.Add(selectionLayer)
Image1.ImageUrl = mapView.Draw().Url |
Remarks
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also