Update Route

Apr 9, 2010 at 7:55 AM

Hello, I'm using the WindowsForms dll on VB.NET 2008 Express.

At least I was able to bring your great control to run, added markes and a route.

I implemented drag and drop of markes by

Private Sub map_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles map.MouseMove
  If e.Button = Windows.Forms.MouseButtons.Left Then
    If DragMarker Then
      gmo.Markers.Item(DraggedMarker - 1).Position = map.FromLocalToLatLng(e.X, e.Y)
      gmo.Routes.Item(0).Points(DraggedMarker - 1) = gmo.Markers.Item(DraggedMarker - 1).Position
    End If
  End If
End Sub

As you can see I also move the route point but the route line is not being updated like the marker. I tried map.refresh(), map.update() even map.reload() without success. Only if I drag the map with the right mouse button the route is being redrawed.

Am I doing something wrong?

P.S.: It was hard for me implemting the control because of the different kinds of code snippets in the discussion and how to's. So for me it's much harder (or impossible) if I would have to download or look into source codes or have to change such code by myself :-P

 

Coordinator
Apr 9, 2010 at 8:06 AM

why do you need to drag route?

Apr 9, 2010 at 8:16 AM

I try to make an application for creating biking trips.

I want to add waypoints (markers) and the route shall be visualized as lines between the waypoints.

When a placement of an marker was not so exactly I want to modify the position of the waypoint by drag and drop (it's easy and possible so far). When I draw the waypoint it would be nice that also the lines between the waypoints is moving too.

At the moment I am deleting the entire route and create it completely new after the drop of the marker (OnMouseUp event) with

gmo.Routes.Clear()
route = New List(Of NET.PointLatLng)

For Each m In gmo.Markers
  route.Add(m.Position)
Next

Dim r As New Gmap.NET.WindowsForms.GMapRoute(route, "test")
gmo.Routes.Add(r)

Thanks for the VERY quick response :-)

 

Coordinator
Apr 9, 2010 at 8:48 AM

i see, hm, well you need to call this then:

foreach(GMapOverlay o in Overlays)
{
     if(o.IsVisibile)
     {
               foreach(GMapRoute obj in o.Routes)
               {
                  UpdateRouteLocalPosition(obj);
               }
      }
}

map.Invalidate(false);

but UpdateRouteLocalPosition is internal, so you need to edit source a bit ;}

Apr 9, 2010 at 9:16 AM

>> but UpdateRouteLocalPosition is internal, so you need to edit source a bit ;}

I expected it - too bad :-/ ;-)

by the way: is there a way to get the index of the marker where the mouse is over? Like

Private Sub map_OnMarkerEnter(ByVal item As NET.WindowsForms.GMapMarker) Handles map.OnMarkerEnter
  OnMarker = True
  SelectedMarker = item.Index
End Sub

Then I could later use this info for other operations like

gmo.Markers(SelectedMarker).Tag = "abc"
gmo.Markers(SelectedMarker).ToolTipText = "abc"
or
gmo.Routes.item(myRoute).Position(SelectedMarker) = ...

I think other useres requested the possibility to drag route points already. This would be the best solution and then all this workaround with extra waypoints is no more used...

And for the wish/ideas-list: It would be nice to have in a route not only the line but also a pin or dot or similar on the points. For example if you have a route which is nearly straight and there is one or more points on this nearly straight line, how can I see where the points are? I mention this because I aleady can import and export GPX files into my application which I am using on my mobile phone for routing/tracking ;-)

 

Coordinator
Apr 9, 2010 at 10:18 AM

why not: SelectedMarker = item ? // if you have the object you can always find the index later

anyway, all you need is just regeneration of route. Just ovveride UpdateRouteLocalPosition. Sure it would be nice, but how to implement it ;}

Coordinator
Apr 9, 2010 at 12:03 PM

check the newest version, I've added some polygon interaction

Jun 2, 2010 at 3:17 PM

Hello radioman,

after a few weeks of abstinence I continue on my project.

I've downloaded the newest version of the DLLs and also tried to use polygons instead of routes.

On the first try it looks like that the polygons are used similar to polygons and the only difference is that the end is connected to the start and the area can be filled. That's -so far - not what I need ;-)

The polygons have the same behaviour as when I change the Position of a route point: The ploygons do not refresh/repaint when a polygon point is being changed. Only dragging the map with the mousebutton, (or zooming) causes that the route or polygon is being redrawed...

I hoped there would be a new "Refresh", "Repaint"or "UpdateRouteLocalPosition" function but unfortunately not.

 

Am I doing something wrong?

 

P.S.: I've been teaching myself programming for much more than 10 years but unfortunately not C, C++, C# or Java... :-(

Coordinator
Jun 2, 2010 at 3:22 PM

MainMap.UpdatePolygonLocalPosition(polygon); // check windows form demo

Jun 2, 2010 at 6:47 PM

Great! :-))) Thanks!