-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapHelper.cs
More file actions
70 lines (60 loc) · 1.98 KB
/
mapHelper.cs
File metadata and controls
70 lines (60 loc) · 1.98 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Bing.Maps;
using Windows.UI.Xaml.Media.Imaging;
namespace App13.Map
{
class mapHelper
{
public Bing.Maps.Map map;
public double clicked_x;
public double clicked_y;
/* only when map used for forms */
public TextBox lat;
public TextBox lan;
/* basic use of map to show places */
public mapHelper(Bing.Maps.Map m)
{
map = m;
}
/* map with form, lat = textbox for Latitude and lan = text box for Longitude */
public mapHelper(Bing.Maps.Map m,TextBox lat,TextBox lan)
{
map = m;
this.lat = lat;
this.lan = lan;
map.PointerPressedOverride += MyMap_PointerPressedOverride;
}
private void MyMap_PointerPressedOverride(object sender, PointerRoutedEventArgs e)
{
map.Children.Clear();
Bing.Maps.Location l = new Bing.Maps.Location();
this.map.TryPixelToLocation(e.GetCurrentPoint(this.map).Position, out l);
Bing.Maps.Pushpin pushpin = new Bing.Maps.Pushpin();
pushpin.SetValue(Bing.Maps.MapLayer.PositionProperty, l);
map.Children.Add(pushpin);
clicked_x = l.Latitude;
clicked_y = l.Longitude;
lat.Text = clicked_x.ToString();
lan.Text = clicked_y.ToString();
}
public void addPoint(double x, double y)
{
Pushpin pushpin = new Pushpin();
pushpin.Text = "1";
MapLayer.SetPosition(pushpin, new Location(x, y));
map.Children.Add(pushpin);
}
}
}