Skip to content

SyncfusionExamples/SfMaps_GettingStarted_UWP

Repository files navigation

Getting Started with UWP Map (SfMaps)

This sample demonstrates how to create a UWP Map using the Syncfusion SfMap control.

Prerequisites

  • Visual Studio 2022 or later
  • Windows 10 SDK (10.0.16299.0 or later)
  • Syncfusion.SfMaps.UWP NuGet package (latest)

Adding Assembly Reference

Option 1: Via NuGet Package Manager

  1. Right-click on the project in Solution Explorer and select Manage NuGet Packages.
  2. Search for Syncfusion.SfMaps.UWP and install it.

Option 2: Via Extension Reference

  1. Open the Add Reference window from your project.
  2. Choose Windows > Extensions > Syncfusion Controls for UWP XAML.

Adding Namespace

After adding the reference, include the following namespace in your MainPage.xaml:

xmlns:syncfusion="using:Syncfusion.UI.Xaml.Maps"

Initializing the Map (XAML)

In MainPage.xaml, initialize SfMap by adding a ShapeFileLayer and setting the Uri property to point to your shape file:

<Page
    x:Class="MapsGettingStarted_Sample.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MapsGettingStarted_Sample"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:syncfusion="using:Syncfusion.UI.Xaml.Maps"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Name="mainGrid">
        <syncfusion:SfMap>
            <syncfusion:SfMap.Layers>
                <syncfusion:ShapeFileLayer   Uri="MapsGettingStarted_Sample.Assets.ShapeFiles.world1.shp">
                </syncfusion:ShapeFileLayer>
            </syncfusion:SfMap.Layers>
        </syncfusion:SfMap>
    </Grid>
</Page>

Initializing the Map (Code-Behind)

Alternatively, you can create the map entirely in C# code-behind:

using Syncfusion.UI.Xaml.Maps;

// Initializing the map
SfMap syncMap = new SfMap();

// Creating and configuring the shape file layer
ShapeFileLayer layer = new ShapeFileLayer();
layer.Uri = "MapsGettingStarted_Sample.Assets.ShapeFiles.world1.shp";

// Adding the layer to the map
syncMap.Layers.Add(layer);

// Adding map to the Grid
mainGrid.Children.Add(syncMap);

Maps getting started image

Reference

About

This repository contains sample to getting started with the Syncfusion UWP maps control.

Topics

Resources

Stars

0 stars

Watchers

3 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages