Identifying Features

Objective: In this lesson, you will learn how to identify features using your application.


Identify functionality allows the user to click on a feature and see information about the feature. To incorporate the identify functionality into your application, you need to do the following:


1. Add a MapToolButton control above the Map control on the form and call it infoTool. Change the Map property to Map1, the MapTool property to Info, the ImageUrl property to "tools/info.gif". 


The Info tool also allows you to pan the map (as the Pan tool) without changing the current map tool.

2. Add a DataGrid (or GridView) control to the form. It will be used to display the found records.


3. Add an event handler for the InfoTool event of Map1 and add the following code. The code uses the Identify method to find features.


Private Sub Map1_InfoTool(ByVal sender As Object, ByVal e As AspMap.Web.InfoToolEventArgs) Handles Map1.InfoTool

        Dim records As AspMap.Recordset = Map1.Identify(e.InfoPoint, 5)

        If (Not records.EOF) Then
                DataGrid1.DataSource = records

                Dim callout As Callout = Map1.Callouts.Add()
                callout.X = e.InfoPoint.X
                callout.Y = e.InfoPoint.Y
                callout.Font.Size = 16

                If records.Layer.LabelField.Length > 0 Then
                        callout.Text = records(records.Layer.LabelField).ToString()
                        callout.Text = records(0).ToString()
                End If
        End If
End Sub

4. Compile and run the application, your map should look similar to the image below:




© 2018 VDS Technologies
Converted from CHM to HTML with chm2web Standard 2.85 (unicode)