https://github.com/syncfusionexamples/integrate-.net-maui-maps-with-android-native-embedding
This repository contains a sample that explain how to integrate .NET MAUI SfMaps with android native embedding.
https://github.com/syncfusionexamples/integrate-.net-maui-maps-with-android-native-embedding
android data-visualization dotnet map maui native-embedding sfmaps
Last synced: 12 days ago
JSON representation
This repository contains a sample that explain how to integrate .NET MAUI SfMaps with android native embedding.
- Host: GitHub
- URL: https://github.com/syncfusionexamples/integrate-.net-maui-maps-with-android-native-embedding
- Owner: SyncfusionExamples
- Created: 2024-04-15T13:30:47.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-09-13T10:27:19.000Z (8 months ago)
- Last Synced: 2025-10-23T10:48:11.531Z (6 months ago)
- Topics: android, data-visualization, dotnet, map, maui, native-embedding, sfmaps
- Language: C#
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# How to integrate .NET MAUI Maps with android native embedding application?
In this article, you will learn how to create a [.NET MAUI Maps](https://www.syncfusion.com/maui-controls/maui-maps) native embedded Android application by following the step by step process explained below.
**Step 1:**
Create a .NET Android application and install the [Syncfusion.Maui.Maps](https://www.nuget.org/packages/Syncfusion.Maui.Maps) nuget package using the [nuget.org](https://www.nuget.org/).
**Step 2:**
In the project file of the native application, add the tag `true` to enable the .NET MAUI support as demonstrated below.
**[XML]:**
```xml
enable
enable
true
```
**Step 3:**
Initialize .NET MAUI in the native app project by creating a **MauiAppBuilder** object and using the **UseMauiEmbedding** function. Then, use the **Build()** method on the **MauiAppBuilder** object to build a **MauiApp** object. Finally, create a **MauiContext** object from the MauiApp object to convert .NET MAUI controls to native types.
**[C#]:**
```csharp
MauiContext? _mauiContext;
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
MauiAppBuilder builder = MauiApp.CreateBuilder();
builder.UseMauiEmbedding();
builder.ConfigureSyncfusionCore();
MauiApp mauiApp = builder.Build();
_mauiContext = new MauiContext(mauiApp.Services, this);
}
```
**Step 4:**
Create a new instance for the SfMaps control, add a shape layer to it, and set the source of the map shapes using the [ShapesSource](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Maps.MapShapeLayer.html#Syncfusion_Maui_Maps_MapShapeLayer_ShapesSource) property of the [MapShapeLayer](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Maps.MapShapeLayer.html).
**[C#]:**
```csharp
protected override void OnCreate(Bundle? savedInstanceState)
{
...
SfMaps map = new SfMaps();
MapShapeLayer layer = new MapShapeLayer();
layer.ShapesSource = MapSource.FromUri(new Uri("https://cdn.syncfusion.com/maps/map-data/world-map.json"));
map.Layer = layer;
...
}
```
**Step 5:**
Convert the Maps control to a platform-specific view for the .NET MAUI framework and set this view as the content view for the current Android activity.
**[C#]:**
```csharp
protected override void OnCreate(Bundle? savedInstanceState)
{
Android.Views.View view = map.ToPlatform(_mauiContext);
// Set our view from the "main" layout resource
SetContentView(view);
}
```
**Output:**
