-
-
Notifications
You must be signed in to change notification settings - Fork 193
/
MainPage.xaml.cs
44 lines (41 loc) · 1.12 KB
/
MainPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
namespace MauiMaps;
using CommunityToolkit.Maui.Alerts;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Maps;
public partial class MainPage : ContentPage
{
public MainPage(MainPageViewModel viewModel)
{
BindingContext = viewModel;
InitializeComponent();
InitMap1();
}
void InitMap1()
{
var pinKyiv = new CustomPin()
{
Label = "Kyiv",
Location = new Location(50.45466, 30.5238),
Address = "Ukraine",
ImageSource = ImageSource.FromUri(new Uri("https://www.gamesatlas.com/images/football/teams/ukraine/dynamo-kyiv.png"))
};
var pinSimferopol = new CustomPin()
{
Label = "Simferopol",
Location = new Location(44.95719, 34.11079),
Address = "Crimea, Ukraine",
ImageSource = ImageSource.FromResource("MauiMaps.Resources.EmbeddedImages.Tavriya.png")
};
MyMap.Pins.Add(pinKyiv);
MyMap.Pins.Add(pinSimferopol);
pinKyiv.InfoWindowClicked += async delegate
{
await Toast.Make("The capital of Ukraine").Show();
};
pinSimferopol.MarkerClicked += async delegate
{
await Toast.Make("Welcome to Crimea").Show();
};
MyMap.MoveToRegion(new MapSpan(new Location(47, 31), 10, 15));
}
}