Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created December 2, 2022 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/bb8c27d16be880709dc1ae5b141a8176 to your computer and use it in GitHub Desktop.
Save icebeam7/bb8c27d16be880709dc1ae5b141a8176 to your computer and use it in GitHub Desktop.
A View that displays a Map in .NET MAUI app.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MapDemo.Views.MapView"
xmlns:maps="clr-namespace:Microsoft.Maui.Controls.Maps;assembly=Microsoft.Maui.Controls.Maps"
xmlns:vm="clr-namespace:MapDemo.ViewModels"
xmlns:models="clr-namespace:MapDemo.Models"
x:DataType="vm:MapViewModel"
Title="MapView">
<Grid Margin="10"
RowSpacing="10"
RowDefinitions="Auto,*">
<Button Text="Get Current Location"
Command="{Binding GetCurrentLocationCommand}"/>
<maps:Map Grid.Row="1"
ItemsSource="{Binding Places}">
<maps:Map.ItemTemplate>
<DataTemplate x:DataType="models:Place">
<maps:Pin Location="{Binding Location}"
Address="{Binding Address}"
Label="{Binding Description}" />
</DataTemplate>
</maps:Map.ItemTemplate>
</maps:Map>
</Grid>
</ContentPage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment