I found some code in discussions to query for features near the mouse cursor. I tried to use this code, but I got not the result I expect.
In my map is one VectorLayer (a shape file) and now I want to know which feature(s) are near the mouse. Maybe too, is a second layer is loaded. At first I got no results on my VectorLayer so I played around with the tools. Then I noticed that I only get results
if features when they are selected.
For tests I set QueryGrowFactor higher and MapQueryMode to AllLAyers. But without any positive effect.
Private Sub MapBox1_MouseMove(worldPos As GeoAPI.Geometries.Coordinate, imagePos As System.Windows.Forms.MouseEventArgs) Handles MapBox1.MouseMove
For Each layer As VectorLayer In Me.MapBox1.Map.Layers
If TypeOf layer Is ICanQueryLayer Then
Dim ds As New SharpMap.Data.FeatureDataSet()
If Not layer.DataSource.IsOpen Then
Dim p As New GeoAPI.Geometries.Envelope(worldPos.CoordinateValue)
' Do whatever you want with ds.Tables(0)
For Each row As SharpMap.Data.FeatureDataRow In ds.Tables(0).Rows
tt &= layer.LayerName & ": " & row.ToString & vbCrLf
Can I also query feature without select them first? How?