Drawing a route via VB.net
Posted: Fri Nov 27, 2015 8:14 am
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.
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.