Hi,
I am having a problem with Internalfeatures.clear method. I need to show a point on a road feature layer when the mouse hovers over a road. This point shoudl disappear when the mouse moves away. Showing the point works fine but when the moves moves away the point does not disappear. I am using Internalfeatures.clear to remove the point shape when the mouse moves away. Also, is there a better way to do this instead of adding a point feature and removing it. eg. Can the point feature's visibility be controlled. I have already tried the isvisible property of the inmemoryfeaturelayer which did not work.
Private Sub WinformsMap1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles WinformsMap1.MouseMove Dim MousePoint As PointShape = ExtentHelper.ToWorldCoordinate(WinformsMap1.CurrentExtent, e.X, e.Y, WinformsMap1.Width, WinformsMap1.Height) Dim ProjectionToWGS84 As New Proj4Projection(Proj4Projection.GetEpsgParametersString(26918), Proj4Projection.GetEpsgParametersString(4326)) ProjectionToWGS84.Open() Dim PointVertex As Vertex Dim FeatureDistance As Double PointVertex = ProjectionToWGS84.ConvertToExternalProjection(MousePoint.X, MousePoint.Y) InfoForm.Latitext.Text = Format(PointVertex.X, "0.0000") InfoForm.Longitext.Text = Format(PointVertex.Y, "0.0000") If ControlForm.MseTool3.Checked = True Then 'WinformsMap1.TrackOverlay.TrackMode = TrackMode.Point Dim RoadDOTLayer As FeatureLayer = WinformsMap1.FindFeatureLayer("ROAD_DOT") Dim TrackPoint As InMemoryFeatureLayer = DirectCast(WinformsMap1.FindFeatureLayer("TrackingPoint"), InMemoryFeatureLayer) TrackPoint.InternalFeatures.Clear() TrackPoint.IsVisible = False Dim tolerance As Double = 0.0001 Dim searchingBoundingBox As RectangleShape = New RectangleShape(MousePoint.X - tolerance, MousePoint.Y + tolerance, MousePoint.X + tolerance, MousePoint.Y - tolerance) RoadDOTLayer.Open() Dim selectedFeaturesRoadDOTLayer As Collection(Of Feature) = RoadDOTLayer.QueryTools.GetFeaturesInsideBoundingBox(searchingBoundingBox, New String(0) {"STREET_NAM"}) RoadDOTLayer.Close() If selectedFeaturesRoadDOTLayer.Count > 0 Then FeatureDistance = selectedFeaturesRoadDOTLayer.Item(0).GetShape().GetDistanceTo(MousePoint, GeographyUnit.Meter, DistanceUnit.Feet) If FeatureDistance <= 10.0 Then WinformsMap1.Overlays("InMemoryOverlay").Lock.EnterWriteLock() Try Dim TrackingShape As PointShape = New PointShape() TrackingShape.Id = "TrackingPoint" TrackPoint.InternalFeatures.Add("TrackingPoint", New Feature(TrackingShape)) TrackPoint.IsVisible = True Dim Point As PointShape = TrackPoint.InternalFeatures("TrackingPoint").GetShape() Dim PointOnRoad As PointShape = selectedFeaturesRoadDOTLayer.Item(0).GetShape().GetClosestPointTo(MousePoint, GeographyUnit.Meter) Point.X = PointOnRoad.X Point.Y = PointOnRoad.Y TrackPoint.Open() TrackPoint.EditTools.BeginTransaction() TrackPoint.EditTools.Update(Point) TrackPoint.EditTools.CommitTransaction() TrackPoint.Close() Finally WinformsMap1.Overlays("InMemoryOverlay").Lock.ExitWriteLock() End Try Else TrackPoint.InternalFeatures.Clear() TrackPoint.IsVisible = False End If Else TrackPoint.InternalFeatures.Clear() TrackPoint.IsVisible = False End If Else 'TrackPoint.IsVisible = False 'WinformsMap1.TrackOverlay.TrackMode = TrackMode.None End If WinformsMap1.Refresh() End Sub