Drawing multiple polyline

Hello,

i have a problem:

at loading of page map i make following action:


stream = assembly.GetManifestResourceStream("Bike.GPX.Ciclabili_FAG_SMIVER-line.shp");

ImageryLayer imageryLayer = new ImageryLayer();

ShapeFileLayer layer = new ShapeFileLayer();

layer.ReadAsStream(stream);

layer.ShapeType = ShapeType.Polyline;

ShapeSetting set= new ShapeSetting();

set.ShapeFill = Color.Blue;

set.SelectedShapeColor = Color.Blue;

set.ShapeStroke=Color.Blue;

layer.ShapeSettings = set;

imageryLayer.Sublayers.Add(layer);

sfmap.Layers.Add(imageryLayer)


Nothing is displayed.

control on xaml is following:


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


 <maps:SfMaps.Layers>


   <maps:ImageryLayer LayerType="OSM" x:Name="layer" ResetOnDoubleTap="False">


<maps:ImageryLayer.Sublayers>


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

  <maps:ShapeFileLayer.Points>

  </maps:ShapeFileLayer.Points>


<maps:ShapeFileLayer.ShapeSettings>


<maps:ShapeSetting x:Name="settings" ShapeStrokeThickness="3" ShapeStroke="#00A0FF" >


</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>






i dont want touch this layer because i need to draw polyline for tracking so i need add anothere for fixed shape (shp) as above.


Can you help me to understand? I already read online documentation but it isn't useful for me.


Thank you



Note, if i make this simply code:

stream = assembly.GetManifestResourceStream("VagoBike.GPX.Ciclabili_FAG_SMIVER-line_cagliari.shp");

subLayer.ReadAsStream(stream);

settings.ShapeFill = Color.Blue;

settings.SelectedShapeColor = Color.Blue;

subLayer.ShapeSettings.ShapeStroke = Color.Blue;

shape works but i cannot draw another polyline with this code:

ShapeFileLayer layer = new ShapeFileLayer();

foreach (var route in openroute.features)

{

subLayer.Points.Clear();

foreach (var coord in route.geometry.coordinates)

{


subLayer.Points.Add(new Point(coord[1], coord[0]));

}

}

settings.ShapeFill = Color.Red;

settings.SelectedShapeColor = Color.Red;

subLayer.ShapeSettings.ShapeStroke = Color.Red;



1 Reply

ET Eswaran Thirugnanasambandam Syncfusion Team May 6, 2022 02:46 PM UTC

We prepared a sample with the provided code snippet and checked the reported problem “shape works but i cannot draw another polyline”. We have also checked by adding multiple polylines with multiple sublayers. But we are unable to reproduce the problem in our side. Please get the tested sample from the below attachment.


If you still face any problem, please revert us by modifying the sample based on your application scenario along with the replication steps. This will allow us to assist you with a better solution as soon as possible.


Attachment: Mapsmain_b8655f66.zip

Loader.
Up arrow icon