-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathXamlProjectionWindow.xaml.cs
More file actions
30 lines (26 loc) · 976 Bytes
/
XamlProjectionWindow.xaml.cs
File metadata and controls
30 lines (26 loc) · 976 Bytes
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
using System;
using System.Windows;
namespace DemosWPF
{
/// <summary>
/// Interaction logic for XamlProjectionWindow.xaml
/// </summary>
public partial class XamlProjectionWindow : Window
{
public XamlProjectionWindow(string accessToken)
{
InitializeComponent();
Map.AccessToken = accessToken;
}
private void Map_Render(object sender, EventArgs e)
{
// Render event is called whenever the map is redrawn
// basically when style/location/pitch/rotation/etc is changed
// We convert a specific lat/lon into pixels
var boxLocation = new MapboxNetCore.GeoLocation(61.767785, 4.898183);
var pointOnScreen = Map.Project(boxLocation);
// then set the box position to those pixels
Box.Margin = new Thickness(pointOnScreen.X - Box.ActualWidth/2, pointOnScreen.Y - Box.ActualHeight/2, 0, 0);
}
}
}