question

aeao-0302 avatar image
0 Votes"
aeao-0302 asked JessieZhang-2116 commented

Xamarin Forms Maps does not visualize polylines

When drawing a list of polylines, only the first line is displayed on the map, the rest are colourless, maxLines = 2130903480 is a large number, it is less than 1000 lines. The coordinates are correct. The same result is obtained with Xamarin.GooglePlayServices.Maps

             Polyline pline;
             for (int i = 0; i < cadL[j].ln.Count; i++)                  // List of line
             {
                 pline = new Polyline();
                 pline.Geopath.Clear();
                 pline.StrokeColor = Color.Blue;
                 pline.StrokeWidth = 4;
                    
                 for (int k = 0; k < cadL[j].ln[i].l.Count; k++)     // List of vertex
                 {
                     //pline.Positions.Add(new Position(cadL[j].ln[i].l[k].x, cadL[j].ln[i].l[k].y));
                     pline.Geopath.Add(new Position(cadL[j].ln[i].l[k].x, cadL[j].ln[i].l[k].y));
                        
                 }
                 customMap.MapElements.Add(pline);
                 //customMap.CustomPLines.Add(pline);
                    
             }


dotnet-xamarin
· 13
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @aeao-0302 ,do you want to draw route with Xamarin Forms Maps?
xamarin forms map control cannot show the route, you could change other nuget plugin to achieve it. such as TK.CustomMap, this nuget package support it: http://torbenk.github.io/TK.CustomMap/.

And here is the sample code about router: https://github.com/TorbenK/TK.CustomMap/blob/Development/Source/Samples/Sample/TK.CustomMap.Sample/ViewModels/AddRouteViewModel.cs .

In addition, you can use Google Apis to generate a route: Google Maps Directions API.


0 Votes 0 ·

Thanks for the suggestion. My problem is not drawing a route, or drawing one by one then they are also visible. But when many routes are drawn in a cycle then only the first is visible, the others are invisible but there are them on the map.

0 Votes 0 ·

Could you please post a basic demo to github or onedriver so that we can test on our side?

1 Vote 1 ·

Sorry for the incorrectly structured project in GitHub, this is the link
https://github.com/aeao-0302/CADView



0 Votes 0 ·

Hi @aeao-0302 , sorry, I couldn't find your full demo or other code snippets except the Latitude and longitude data in the link you posted.

1 Vote 1 ·

0 Answers