Drawing a route via VB.net

Within this forum we want to offer discussions all around our .NET based Map control including all .Net-language specific questions concerning calls of the xServer-API. Attention: xServer-relevant concepts can be found in further forums such as xRoute or xTour.
Post Reply
ggiardina
Posts: 5
Joined: Thu May 08, 2014 6:52 am

Drawing a route via VB.net

Post by ggiardina »

Hello,
I'm supporting a customer of ours in order to use xServer.NET via vb.net but I can't reproduce the c# example in order to draw a route using a MapPolyline. Here is what I did:

this is the xRoute call and it works well returning the correct info and linestring:
Dim route As New Route
route = XRouteWSService1.calculateRoute(wayPoints, Nothing, Nothing, resultListOption, callerContext)


this is how I get points for the polyline:
Dim points As New PointCollection
For Each pp As XRoute.PlainPoint In route.polygon.lineString.wrappedPoints
points.Add(New Point(pp.x, pp.y))
Next


and here is the routing layer creation:
Dim routePolyLine As New MapPolyline
routePolyLine.Points = points
routePolyLine.Width = 10
routePolyLine.StrokeLineJoin = PenLineJoin.Round
routePolyLine.StrokeStartLineCap = PenLineCap.Round
routePolyLine.StrokeEndLineCap = PenLineCap.Round
routePolyLine.MapStrokeThickness = 50
routePolyLine.ScaleFactor = 0.1
routePolyLine.Visibility = True
routePolyLine.Stroke = New SolidColorBrush(Color.FromRgb(255, 0, 255))

routingLayer.Priority = 4
routingLayer.Shapes.Add(routePolyLine)
routingLayer.Refresh()

FormsMap1.Layers.Add(routingLayer)


the shape layer was previously created like this:
Dim routingLayer As New ShapeLayer("Percorsi")

If I create a layer with all points in the linestring I can show them correctly but MapPolyline does not. Due to the fact I did not find anything about vb.net I kindly ask you some tips.

Thank in advance!

Regards,
Giovanni.
User avatar
Oliver Heilig
Posts: 160
Joined: Tue May 13, 2014 12:10 pm
Location: Karlsruhe, Germany
Contact:

Re: Drawing a route via VB.net

Post by Oliver Heilig »

Hello Giovanni,

i've added the calculation and displaying of a route to FormsMapCS and FormsMapVB at https://github.com/ptv-logistics/xservernet-bin

Image

Regards

Oliver
ggiardina
Posts: 5
Joined: Thu May 08, 2014 6:52 am

Re: Drawing a route via VB.net

Post by ggiardina »

Thank you very much Oliver, it works perfectly.
Is it also possible to adapt drag&drop routing in vb.net ? For sure the customer will ask for this in the next future.

Best regards,
Giovanni.
User avatar
Oliver Heilig
Posts: 160
Joined: Tue May 13, 2014 12:10 pm
Location: Karlsruhe, Germany
Contact:

Re: Drawing a route via VB.net

Post by Oliver Heilig »

Hi Giovanni,

yes this is possible. We have a sample in the DemoCenter that shows howto implement Drag&Drop routing with xServer.NET. But porting the whole sample to VB would be much work. An option would be to extract this code to an assembly an use this from the VB application.

I'll take a look at it tomorrow.

Oliver
User avatar
Oliver Heilig
Posts: 160
Joined: Tue May 13, 2014 12:10 pm
Location: Karlsruhe, Germany
Contact:

Re: Drawing a route via VB.net

Post by Oliver Heilig »

Hi Giovanni,

added a sample "RoutingVB" to https://github.com/ptv-logistics/xservernet-bin. It's a little bit rough on the edges, but shows how to add the sample code from the DemoCenter to your VB.NET application.

It would be possible to extend this to a generic interactive C#/VB router like "leaflet-routing-machine" for JavaScript http://ptv-logistics.github.io/lrm-ptv/. But this would be still some way to go :D

Oliver
Post Reply