Zooming to a selected item- SOAP Controls

The ability to zoom in to a selected item in an overlay can be useful in ‘search and identify’ operations. We can extend the method we just created to find the map item nearest to the user’s click and zoom so that it fills the map window:

Private Sub ImageButton1_Click(ByVal sender As System.Object, 
ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click   
' e contains the coordinates of where the user clicked, in pixels
   ' Use GeognoSIS to convert them to real-world coordinates   Dim v As SisVector = oSis.GetViewPos(e.X, e.Y, ImageButton1.Width.Value, ImageButton1.Height.Value)
   ' Write them into the label   coordsLabel.Text = "Coordinates: (" & v.x & ", " & v.y & ")"
   ' Work out a reasonable search radius   Dim ex As SisExtent = oSis.SplitExtent(oSis.GetViewExtent())
   Dim r = (ex.max.x - ex.min.x)
   Try     ' Locate the item - may not succeed
     oSis.OpenClosestItem(v.x, v.y, v.z, r, "H", "")
     oSis.AddToList("SelectedItem")     ' Get the extent of the list and sets the map window to it.
     ex = oSis.SplitExtent(oSis.GetListExtent("SelectedItem"))
     oSis.EmptyList("SelectedItem")     oSis.SetViewExtent(ex.min.x, ex.min.y, 0, ex.max.x, ex.max.y, 0)
     RenderSis()
   Catch x As Exception
     ' No item was found - so do nothing more
   End TryEnd Sub