I'm trying to set the extent of a map based of the features of a layer that has a filter delegate.
Here's the code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim FilterLayer As New Layers.VectorLayer("EXTENT")
Dim ShapeFile As Data.Providers.ShapeFile
ShapeFile = New Data.Providers.ShapeFile("D:\Data\ThematicMap\Shapes\US_COUNTIES.shp")
ShapeFile.FilterDelegate = AddressOf FilterByIDs
FilterLayer.DataSource = ShapeFile
Dim fMap As New SharpMap.Map
Private Function FilterByIDs(ByVal dr As Data.FeatureDataRow) As Boolean
If dr("FIPS").ToString.ToUpper = "40001".ToUpper Then
I've set a breakpoint in the delegate and it doesnt ever seem to get called. And, I guess I'm not sure from the documentation where I should go looking for the extent / envelope once it does get called. Will I need to ZoomToExtents once the layer is filtered
and then grab map.envelope?
Any help is appreciated.
Sep 14, 2006 at 6:46 AM
The FilterDelegates is only applied in the renderingstep, and thus not a part of the envelope.
You can use one of the database providers and apply the DefinitionQuery as a filter instead. Using this will also effect the envelope of the dataset.
So, if I want to get the extent of several features and the data is in a shapefile the way to go about this is to open up the file and grab the geometry's envelope?