This sample demonstrates how to create and customize a Syncfusion® WinForms Maps control.
- Visual Studio 2022 or later
- .NET Framework 4.7.2 or later
- Syncfusion
Syncfusion.Maps.WindowsNuGet package
To use the Maps control, add the following NuGet packages to your project:
Open the Package Manager Console and run:
Install-Package Syncfusion.Maps.Windows
Install-Package Syncfusion.Shared.Base
Install-Package Syncfusion.Shared.Windows
Install-Package Syncfusion.Licensing
Or, add the references directly in your .csproj file:
<ItemGroup>
<PackageReference Include="Syncfusion.Maps.Windows" Version="*" />
<PackageReference Include="Syncfusion.Shared.Base" Version="*" />
<PackageReference Include="Syncfusion.Shared.Windows" Version="*" />
<PackageReference Include="Syncfusion.Licensing" Version="*" />
</ItemGroup>Open Visual Studio, create a new Windows Forms App project targeting .NET Framework 4.7.2 or higher.
In the Form1.Designer.cs (or code-behind), initialize and add the Maps control:
using Syncfusion.Windows.Forms.Maps;
// Initialize the Maps control
this.mapsControl1 = new Syncfusion.Windows.Forms.Maps.Maps();
// Set properties
this.mapsControl1.Name = "mapsControl1";
this.mapsControl1.Size = new System.Drawing.Size(880, 585);
// Add to the form
this.Controls.Add(this.mapsControl1);In the Form1.cs file, add a ShapeFileLayer to display map data:
using Syncfusion.Windows.Forms.Maps;
using System;
using System.Windows.Forms;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
ShapeFileLayer shapeLayer = new ShapeFileLayer();
shapeLayer.Uri = "world1.shp";
this.mapsControl1.Layers.Add(shapeLayer);
}
}- Clone or download this repository.
- Open
MapsGettingStarted.slnin Visual Studio. - Restore NuGet packages.
- Build and run the project (
F5).
