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.
Drawing a route via VB.net
- Oliver Heilig
- Posts: 160
- Joined: Tue May 13, 2014 12:10 pm
- Location: Karlsruhe, Germany
- Contact:
Re: Drawing a route via VB.net
Hello Giovanni,
i've added the calculation and displaying of a route to FormsMapCS and FormsMapVB at https://github.com/ptv-logistics/xservernet-bin
Regards
Oliver
i've added the calculation and displaying of a route to FormsMapCS and FormsMapVB at https://github.com/ptv-logistics/xservernet-bin
Regards
Oliver
Re: Drawing a route via VB.net
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.
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.
- Oliver Heilig
- Posts: 160
- Joined: Tue May 13, 2014 12:10 pm
- Location: Karlsruhe, Germany
- Contact:
Re: Drawing a route via VB.net
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
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
- Oliver Heilig
- Posts: 160
- Joined: Tue May 13, 2014 12:10 pm
- Location: Karlsruhe, Germany
- Contact:
Re: Drawing a route via VB.net
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
Oliver
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
Oliver