我需要帮助,或者至少是一个让事情有效的想法。
我正在通过gps路由某事的旅行。
首先,我在我的.accdb(3分)上预装了latlng积分
我希望他们通过路线连接。
在这里:
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识别最后一个标记?从那里开始,结束新的..
或者我想要的标记作为起点和终点。谢谢你
答案 0 :(得分: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