ThinkGeo.com    |     Documentation    |     Premium Support

Capture MouseOver data in a shapefile

I had to ask I have gone code blind. How do I capture the label information I used when creating a new shapefilefeaturelayer to display on the MouseOver event?

    Dim BufferLayer As New ShapeFileFeatureLayer(Application.StartupPath + "\Buffer_50.shp")
    Dim BufferTextStyle As New TextStyle("BufferID", New GeoFont("Arial", 10, DrawingFontStyles.Regular), New GeoSolidBrush(GeoColor.StandardColors.DarkOrchid))

Hi Craig,

Attached is a sample(C#) which shows your requirement, please check it out.

If something misunderstood here. Please provide more information.

Desktop_CaptureLabelInformationSample.zip (106.7 KB)

Thanks,
Emil

OK I have a solution almost, I really have to micro-manage the mouse to get this to work, I am trying to build a tolerance in to the routine, I think I am missing something, I am not sure why distance is ever 0, it should never be 0.

    If Map.Overlays.Contains("BufferOverlay") Then
      Dim features As Collection(Of Feature)
      features = Globals.BufferShapeQuery.QueryTools.GetFeaturesNearestTo(currentCoords, GeographyUnit.DecimalDegree, 1, ReturningColumnsType.AllColumns)
      Dim lineShape As New MultilineShape(features(0).WellKnownBinary)
      Dim closestPoint As PointShape = lineShape.GetClosestPointTo(currentCoords, GeographyUnit.DecimalDegree)
      Dim distance As Double = closestPoint.GetDistanceTo(lineShape, GeographyUnit.DecimalDegree, DistanceUnit.Feet)
      Debug.Print(distance.ToString)
      If distance > 0 Then
        If features(0).ColumnValues("ID").ToString.Length > 0 Then
          pipelineTooltip1 = pipelineTooltip1 & " ID: "
          pipelineTooltip2 = pipelineTooltip2 & features(0).ColumnValues("ID").ToString
        End If
      End If
    End If

Hi Craig,

You call lineShape.GetClosestPointTo API, the return point is in the lineshape, then you calculate the distance between the point and the lineShape, sometimes it will be zero, but because the precision problem, if the line is not horizontal or vertical, the result shouldn’t be zero.

Regards,

Don

Working, it was right in front of me.

   If Map.Overlays.Contains("BufferOverlay") Then
     Dim features As Collection(Of Feature)
     Dim ColumnNames As IEnumerable(Of String) = New List(Of String)(New String() {"SHAPE__ID", "DESIG", "ERNum", "ServiceDate", "Own", "Oper", "ID", "SP", "EP"})
     features = Globals.BufferShapeQuery.QueryTools.GetFeaturesNearestTo(currentCoords, GeographyUnit.DecimalDegree, 1, ColumnNames, (300 * zoomMultiplier), DistanceUnit.Feet)
      If features.Count > 0 Then
        If features(0).ColumnValues("ID").ToString.Length > 0 Then
          pipelineTooltip1 = pipelineTooltip1 & " ID: "
          pipelineTooltip2 = pipelineTooltip2 & features(0).ColumnValues("ID").ToString
        End If
      End If
    End If

Thanks

Hi Craig,

I am glad to hear that works, and thanks for your share.

Any question please let us know.

Regards,

Don