Skip to content

Commit

Permalink
added map page
Browse files Browse the repository at this point in the history
  • Loading branch information
davidortinau committed Sep 28, 2022
1 parent a585e92 commit 978a59e
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 44 deletions.
1 change: 1 addition & 0 deletions src/ControlGallery/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private void RegisterRoutes()
Routing.RegisterRoute(nameof(EntryPage), typeof(EntryPage));
Routing.RegisterRoute(nameof(ImagePage), typeof(ImagePage));
Routing.RegisterRoute(nameof(LabelPage), typeof(LabelPage));
Routing.RegisterRoute(nameof(MapPage), typeof(MapPage));
Routing.RegisterRoute(nameof(ProgressBarPage), typeof(ProgressBarPage));
Routing.RegisterRoute(nameof(RadioButtonPage), typeof(RadioButtonPage));
Routing.RegisterRoute(nameof(ShapesPage), typeof(ShapesPage));
Expand Down
2 changes: 2 additions & 0 deletions src/ControlGallery/ControlGallery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@
<ItemGroup>
<None Remove="CommunityToolkit.Maui" />
<None Remove="CommunityToolkit.Mvvm" />
<None Remove="Microsoft.Maui.Controls.Maps" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="1.3.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="Microsoft.Maui.Controls.Maps" Version="7.0.0-rc.1.6687" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions src/ControlGallery/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

using Microsoft.Maui.Handlers;
using static Microsoft.Maui.Controls.Button;
using Microsoft.Maui.Controls.Maps;

#if IOS || MACCATALYST
using UIKit;
Expand All @@ -26,6 +27,7 @@ public static MauiApp CreateMauiApp()
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.UseMauiMaps()
.ConfigureFonts(fonts =>
{
fonts.AddFont("fa_solid.ttf", "FontAwesome");
Expand Down

This file was deleted.

This file was deleted.

11 changes: 11 additions & 0 deletions src/ControlGallery/Pages/Controls/MapPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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="ControlGallery.Pages.MapPage"
Title="Map">
<ContentPage.Content>
<Grid>
<Map x:Name="map"/>
</Grid>
</ContentPage.Content>
</ContentPage>
26 changes: 26 additions & 0 deletions src/ControlGallery/Pages/Controls/MapPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace ControlGallery.Pages;

public partial class MapPage : ContentPage
{
public MapPage()
{
InitializeComponent();
}

protected override void OnNavigatedTo(NavigatedToEventArgs args)
{
base.OnNavigatedTo(args);

var hanaLoc = new Location(20.7557, -155.9880);

MapSpan mapSpan = MapSpan.FromCenterAndRadius(hanaLoc, Distance.FromKilometers(3));
map.MoveToRegion(mapSpan);

map.Pins.Add(new Pin
{
Label = "Welcome to .NET MAUI!",
Location = hanaLoc,
});
}

}
3 changes: 3 additions & 0 deletions src/ControlGallery/Pages/ControlsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@
<m:NavItem Title="Labels"
Icon="view_label.png"
Destination="{x:Type p:LabelPage}"/>
<m:NavItem Title="Map"
Icon="view_map.png"
Destination="{x:Type p:MapPage}"/>
<m:NavItem Title="Picker"
Icon="view_picker.png"
Destination="{x:Type p:PickerPage}"/>
Expand Down
4 changes: 2 additions & 2 deletions src/ControlGallery/Pages/Features/ContextMenuPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
x:Class="ControlGallery.Pages.ContextMenuPage"
Title="ContextMenu">
<ScrollView>
<StackLayout Margin="15" Spacing="8">
<StackLayout Margin="15" Spacing="16">
<Label Text="ContextMenu" Style="{StaticResource Headline}"/>
<Label Text="Right-click the Button for additional actions"/>
<Button
Expand All @@ -14,7 +14,7 @@
ToolTipProperties.Text="More than meets the eye"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Center">
HorizontalOptions="Start">
<FlyoutBase.ContextFlyout>
<MenuFlyout>
<MenuFlyoutItem Text="Increment by 10" Clicked="OnIncrementMenuItemClicked" CommandParameter="10"></MenuFlyoutItem>
Expand Down
4 changes: 3 additions & 1 deletion src/ControlGallery/_usings.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
global using CommunityToolkit.Maui;
global using CommunityToolkit.Mvvm.ComponentModel;
global using CommunityToolkit.Mvvm.Input;
global using CommunityToolkit.Mvvm.Input;
global using Microsoft.Maui.Maps;
global using Microsoft.Maui.Controls.Maps;

0 comments on commit 978a59e

Please sign in to comment.