0

我需要帮助,或者至少是一个让事情顺利进行的想法。

我正在通过 gps路由某物
的行程。 首先,我在我的 .accdb 上预加载了 latlng 点(3 分)
我希望它们通过一条路线连接..
这里:

For Each dtrow In gpsDtable.Rows
        gpsMarker = New GMapMarker_Custom(New PointLatLng(dtrow("Latitude"), dtrow("Longitude")), "vistaMarker")
        routes.Markers.Add(gpsMarker)
        'this code, adds all 3 points in the map as a marker..
        'yes it shows those 3. working good... then

        If routes.Markers.Count < 2 Then
           'this condition is, I think optional
           'I just used them because, routing needs to have 2 POINTS
           'so if there is no marker present, either side, exception
           'if there are 2, execute the code

        Else
           'this is the code to add the route between 2 points

            Dim rp As RoutingProvider = TryCast(mainMap.MapProvider, RoutingProvider)
            Dim route As MapRoute = rp.GetRouteBetweenPoints(gpsMarker.Position, gpsMarker.Position, False, False, CInt(mainMap.Zoom))
           'as you can see, I used gpsMarker as the first & last point
           'logically, I need it to be the same because
           'it will connect to itself since I use for each

            Dim r As New GMapRoute(route.Points, "")
            routes.Routes.Add(r)
        End If
    Next

在我的理论中..
试图测试这个期望有:添加标记,路线,添加第二个标记,路线,添加第三个标记等等..
它出来了,我认为,它路由,但只有一个路由标记,最后一个。所以从技术上讲,你不会看到路线。I start here, I stop here- 类似的事情正在发生。

我在想你能不能帮我出个主意,比如..

For each point in database  
add marker  
add second marker  
route  
add third  
route from second to third
and so on...

VB有没有办法识别最后一个标记?从那里开始并以新的结束..
或我想成为起点和终点的标记。谢谢

4

1 回答 1

1
rp.GetRouteBetweenPoints(gpsMarker.Position, gpsMarker.Position, False, False, CInt(mainMap.Zoom))

据我所知,您设置了一条从gpsMarker自身到自身的路线。

如果您想路线经过每个点的旅行,gpsDtable.Rows那么您可以将每个标记与前一个标记连接起来。像这样的东西:

'DISCLAIMER: untested code
Dim rp As RoutingProvider = TryCast(mainMap.MapProvider, RoutingProvider)
Dim previousGpsMarker As GMapMarker_Custom
For Each dtrow In gpsDtable.Rows
    gpsMarker = New GMapMarker_Custom(New PointLatLng(dtrow("Latitude"), dtrow("Longitude")), "vistaMarker")
    routes.Markers.Add(gpsMarker)
    'If it's not a starting point
    If previousGpsMarker IsNot Nothing Then
        'Set a route from previous marker
        Dim route As MapRoute = rp.GetRouteBetweenPoints(previousGpsMarker.Position, gpsMarker .Position, False, False, CInt(mainMap.Zoom))            
        Dim r As New GMapRoute(route.Points, "")
        routes.Routes.Add(r)
    End If
    'Storing the previous marker
    previousGpsMarker = gpsMarker
Next
于 2013-12-27T07:52:07.323 回答