How to Load Shape Files from Stream in the .NET MAUI Maps (SfMaps)
In the Syncfusion .NET MAUI Maps control, you can load shape files from a stream by following the below demonstration.
Initialize the SfMaps control and initiate the MapShapeLayer.
XAML:
<map:SfMaps>
<map:SfMaps.Layer>
<map:MapShapeLayer x:Name="layer"></map:MapShapeLayer>
</map:SfMaps.Layer>
</map:SfMaps>
Provide the ShapeSource as a stream using the GetManifestResourceStream method by following this demonstration to load shape files as a stream.
XAML:
public MainPage()
{
InitializeComponent();
Assembly assembly = Application.Current.GetType().Assembly;
var jsonStream = assembly?.GetManifestResourceStream("ShapeFileAsStream.Resources.australia.json");
this.layer.ShapesSource = MapSource.FromStream(jsonStream);
}
Output:
Conclusion:
I hope you enjoyed learning how to load shape files from a stream in the .NET MAUI Maps (SfMaps).
Refer to our .NET MAUI Maps feature tour page to learn its other groundbreaking feature representations. You can explore our .NET MAUI Maps documentation to understand how to present and manipulate data.
For current customers, you can check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion, try our 30-day free trial to check out our .NET MAUI Maps and other .NET MAUI components.
Please let us know in the following comments section if you have any queries or require clarifications. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!