Draw Polyline

Hello, i'm using youur trial sfmap from nuget with OSM and openroute for calculate track line. Now i need to draw line on the map:

I write this cs code:

foreach (var coord in route.geometry.coordinates)

{

var geoPoint = layer.GetLatLonFromPoint(new Point(Convert.ToDouble(coord[0]), Convert.ToDouble(coord[1])));

MapMarker marker = new MapMarker();

marker.Latitude = geoPoint.Y.ToString();

marker.Longitude = geoPoint.X.ToString();


layer.Markers.Add(marker);


point = new Point(geoPoint.Y, geoPoint.X);


subLayer.Points.Add(new Point(geoPoint.Y, geoPoint.X));

}

and in the XAML:

    <maps:SfMaps x:Name="sfmap" ZoomLevel="3" >

                <maps:SfMaps.Layers>

                    <maps:ImageryLayer LayerType="OSM"

                           x:Name="layer">

                    <maps:ImageryLayer.Sublayers >

                        <maps:ShapeFileLayer x:Name="subLayer" ShapeType="Polyline" >

                            <maps:ShapeFileLayer.ShapeSettings>

                                <maps:ShapeSetting ShapeStrokeThickness="4" ShapeStroke="Red" ></maps:ShapeSetting>

                            </maps:ShapeFileLayer.ShapeSettings>

                        </maps:ShapeFileLayer>

                    </maps:ImageryLayer.Sublayers>

                    <maps:ImageryLayer.MarkerTemplate>

                        <DataTemplate>

                            <Image x:Name="markerImage"

                            HorizontalOptions="Center"

                            Source="{Binding Image}"

                            VerticalOptions="Center"

                            HeightRequest="25"

                            WidthRequest="25" />

                        </DataTemplate>

                    </maps:ImageryLayer.MarkerTemplate>

                </maps:ImageryLayer>

                </maps:SfMaps.Layers>

            </maps:SfMaps>


No way to see line drawed on the


3 Replies

VR Vignesh Ramesh Syncfusion Team February 3, 2022 12:50 PM UTC

Hi Fabio, 

We have prepared a sample based on the provided snippet and checked the reported problem by providing the geo points directly since we are not aware of the points you have provided in the sample. But we are unable to reproduce the reported problem and the polyline is rendering correctly. Please check the tested sample from the attachment. 


Also, we have published a knowledge base for drawing the polyline on the map by converting the screen point to a lat-long point using the GetLatLonFromPoint method. Please find the link below 


We have suspected that you are providing points wrongly. Please check it once from your side. If you still face any problem, can you revert us by modifying the sample based on your scenario, this will help us to provide you with a better solution at the earliest. 

Regards, 
Vignesh Ramesh. 



FA Fabio replied to Vignesh Ramesh February 3, 2022 01:11 PM UTC

My dear,

I am grateful to you for support but problem was my fault. I inverted latitude with longitude so code was working but nothing was draw. LOL


Solved inverting values.


Thank you



VR Vignesh Ramesh Syncfusion Team February 4, 2022 06:29 AM UTC

Hi Fabio, 
  
We are glad to hear that the problem resolved at your end. Please get in touch with us if you would require any further assistance. 
  
Regards,  
Vignesh Ramesh. 


Loader.
Up arrow icon