Implemented mapcontrol

This commit is contained in:
2016-01-21 22:52:47 +01:00
parent db999b02bd
commit 37d3cedd29
4 changed files with 62 additions and 2 deletions
+21
View File
@@ -7,8 +7,10 @@ using System.Threading.Tasks;
using Windows.Data.Xml.Dom;
using Windows.Devices.Geolocation;
using Windows.Services.Maps;
using Windows.UI;
using Windows.UI.Notifications;
using Windows.UI.Popups;
using Windows.UI.Xaml.Controls.Maps;
namespace YJMPD_UWP.Helpers
{
@@ -130,6 +132,25 @@ namespace YJMPD_UWP.Helpers
return address;
}
public static MapPolyline GetRouteLine(BasicGeoposition p1, BasicGeoposition p2, Color color, int zindex, int thickness = 5)
{
var line = new MapPolyline
{
StrokeThickness = thickness,
StrokeColor = color,
StrokeDashed = false,
ZIndex = zindex
};
List<BasicGeoposition> plist = new List<BasicGeoposition>();
plist.Add(p1);
plist.Add(p2);
line.Path = new Geopath(plist);
return line;
}
public static double Distance(BasicGeoposition pos1, BasicGeoposition pos2)
{
var R = 6371; // Radius of the earth in km
+4 -1
View File
@@ -96,8 +96,11 @@ namespace YJMPD_UWP.Model
App.Game.StopMatch();
break;
case Command.StopGame:
if(App.Game.Status != GameHandler.GameStatus.STOPPED)
if (App.Game.Status != GameHandler.GameStatus.STOPPED)
{
Util.ShowToastNotification("Game stopped", "A player has left the game.");
App.Game.StopGame();
}
break;
default:
//Do nothing
+2
View File
@@ -216,6 +216,8 @@ namespace YJMPD_UWP.Model
Settings.Statistics.AddPoints(GetPlayer(Settings.Username).Points);
Settings.SaveStatistics();
GeofenceMonitor.Current.Geofences.Clear();
Selected = false;
App.Photo.Reset();
+35 -1
View File
@@ -1,4 +1,8 @@
using Windows.UI.Xaml.Controls;
using Windows.Devices.Geolocation;
using Windows.UI;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Maps;
using YJMPD_UWP.Helpers;
using YJMPD_UWP.ViewModels;
namespace YJMPD_UWP.Views
@@ -6,12 +10,42 @@ namespace YJMPD_UWP.Views
public sealed partial class MatchView : Page
{
MatchVM matchvm;
MapIcon pos;
Geoposition old;
public MatchView()
{
matchvm = new MatchVM();
this.DataContext = matchvm;
this.InitializeComponent();
pos = new MapIcon();
pos.Title = "You";
pos.ZIndex = 100;
App.Geo.OnPositionUpdate += Geo_OnPositionUpdate;
}
private void Geo_OnPositionUpdate(object sender, Helpers.EventArgs.PositionUpdatedEventArgs e)
{
Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
{
pos.Location = e.Position.Coordinate.Point;
if (!Map.MapElements.Contains(pos))
Map.MapElements.Add(pos);
if(old != null && !App.Game.Selected)
{
Map.MapElements.Add(Util.GetRouteLine(old.Coordinate.Point.Position, e.Position.Coordinate.Point.Position, Color.FromArgb(255, 200, 50, 50), 50));
}
old = e.Position;
Map.TrySetViewAsync(e.Position.Coordinate.Point);
Map.TryZoomToAsync(13);
});
}
}
}