Reputation: 29
I.m using .NET MAUI's Map control (Microsoft.Maui.Controls.Maps) and I want to reflect the Light/Dark mode of the device. Google maps has a dark mode, but I cannot figure out how to select the dark mode when opening the maå from MAUI (in C#:
map = new Map(mapSpan)
{
MapType = MapType.Street,
IsShowingUser = true,
IsScrollEnabled = true,
IsZoomEnabled = true,
IsTrafficEnabled = false
};
layout.Add(map);)
.NET MAUI documentation on Maps does not include any mentioning of AppThemeBinding or any dark/light mode parameters.
Can anyone help please?
Going through documentation, youtube videos, testing parameters to Map class with no result.
Upvotes: 0
Views: 242
Reputation: 1
You can try this codes.
Map map = new Map(mapSpan)
{
IsShowingUser = true,
IsScrollEnabled = true,
IsZoomEnabled = true,
IsTrafficEnabled = false
};
Application.Current.RequestedThemeChanged += (s, e) =>
{
AppTheme currentTheme = Application.Current.RequestedTheme;
map.MapType = currentTheme == AppTheme.Dark ? MapType.StreetNight : MapType.Street;
};
layout.Add(map);
Upvotes: 0