Articles in this section
Category / Section

How to create map from GeoJson shape file using .NET MAUI Maps?

5 mins read

This article describes how to create a map from GeoJSON data or a shapefile in the Syncfusion® .NET MAUI Maps control.

 

The Syncfusion® .NET MAUI Maps supports both shape and JSON files. you can load from various sources.

  • FromFile returns a MapSource that reads a shape source from a local file.
  • FromUri returns a MapSource that downloads and reads a shape source from a specified URI.
  • FromResource returns a MapSource that reads a shape source file embedded in an assembly.
  • FromStream returns a MapSource that reads a shape source from a stream that supplies source data.

How to load an embedded file

  • You can load both the JSON data and the shapefile.
  • For example, placing australia.json in the root folder of a project named MyProject will result in a resource ID of MyProject.australia.json. Similarly, placing world1.shp in the Assets folder of a project named MyProject will result in a resource ID of MyProject.Assets.world1.shp.
  • Right-click the added shapefile and navigate to properties.
  • Choose the EmbeddedResource option under the BuildAction of the respective shapefile.

 

The following code sample demonstrates how to load a shape file from an embedded.

 

C#

SfMaps map = new SfMaps();
MapShapeLayer layer = new MapShapeLayer();
layer.ShapesSource = MapSource.FromResource("GeoJsonMap.ShapeFiles.world1.shp ");
map.Layer = layer;

 

The following code snippet demonstrates how to load a JSON file from embedded.

 

C#

SfMaps map = new SfMaps();
MapShapeLayer layer = new MapShapeLayer();
layer.ShapesSource = MapSource.FromResource("GeoJsonMap.ShapeFiles.world-map.json ");
map.Layer = layer;
Note:

Please refer to the following reference links for more information on how to load the shapes from other sources.

 

Download the complete sample on GitHub.

 

Output

 

Load an shape to online GeoJson data using Syncfusion .NET MAUI Maps control

 

Conclusion

I hope you enjoyed learning how to create a map from a GeoJSON shape file using .NET MAUI Maps.

You can refer to our .NET MAUI Maps feature tour page to learn about its other groundbreaking feature representations. Explore our documentation to understand how to create and manipulate data.

For current customers, 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 comments section if you have any queries or require clarification. Contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied