Nextrek
Diff Revisions
751
vs
752
for /Android/SmartCharging/SmartCharging_WP/SmartCharging/MapAddressSelectorControl.xaml.cs
|
@@ -1,4 +1,5 @@ |
1 |
|
- |
using System; |
|
1 |
+ |
using SmartCharging.Converter; |
|
2 |
+ |
using System; |
2 |
3 |
|
using System.Collections.Generic; |
3 |
4 |
|
using System.ComponentModel; |
4 |
5 |
|
using System.IO; |
|
@@ -81,17 +82,20 @@ |
81 |
82 |
|
MapLocation mapLocation = ((sender as Control).DataContext as MapLocation); |
82 |
83 |
|
this.siteLocation = mapLocation; |
83 |
84 |
|
|
|
85 |
+ |
this.addMapIcon(mapLocation.Point); |
|
86 |
+ |
MapControl.Center = mapLocation.Point; |
|
87 |
+ |
MapControl.ZoomLevel = 15; |
|
88 |
+ |
} |
|
89 |
+ |
|
|
90 |
+ |
private void addMapIcon(Geopoint point){ |
84 |
91 |
|
MapIcon MapIcon1 = new MapIcon(); |
85 |
|
- |
MapIcon1.Location = mapLocation.Point; |
|
92 |
+ |
MapIcon1.Location = point; |
86 |
93 |
|
MapIcon1.NormalizedAnchorPoint = new Point(1.0, 0.5); |
87 |
94 |
|
MapIcon1.Visible = true; |
88 |
95 |
|
MapIcon1.ZIndex = int.MaxValue; |
89 |
96 |
|
MapIcon1.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/position.png")); |
90 |
97 |
|
MapControl.MapElements.Clear(); |
91 |
98 |
|
MapControl.MapElements.Add(MapIcon1); |
92 |
|
- |
|
93 |
|
- |
MapControl.Center = mapLocation.Point; |
94 |
|
- |
MapControl.ZoomLevel = 15; |
95 |
99 |
|
} |
96 |
100 |
|
|
97 |
101 |
|
|
|
@@ -191,6 +195,28 @@ |
191 |
195 |
|
return result; |
192 |
196 |
|
} |
193 |
197 |
|
|
|
198 |
+ |
public async Task SetInitialPosition(Geopoint position) |
|
199 |
+ |
{ |
|
200 |
+ |
MapLocationFinderResult result = await MapLocationFinder.FindLocationsAtAsync(position); |
|
201 |
+ |
|
|
202 |
+ |
// If the query returns results, display the name of the town |
|
203 |
+ |
// contained in the address of the first result. |
|
204 |
+ |
if (result.Status == MapLocationFinderStatus.Success) |
|
205 |
+ |
{ |
|
206 |
+ |
AddressToStringConverter aTsC = new AddressToStringConverter(); |
|
207 |
+ |
MapLocation ml = result.Locations[0]; |
|
208 |
+ |
this.townLocation = ml; |
|
209 |
+ |
this.siteLocation = ml; |
|
210 |
+ |
|
|
211 |
+ |
this.TownTextBox.Text =ml.Address.Town + ", " + ml.Address.Country; |
|
212 |
+ |
this.AddressTextbox.Text = (string)aTsC.Convert(ml.Address, null, null, null); |
|
213 |
+ |
this.AddressTextbox.IsEnabled = true; |
|
214 |
+ |
this.addMapIcon(ml.Point); |
|
215 |
+ |
MapControl.Center = ml.Point; |
|
216 |
+ |
MapControl.ZoomLevel = 15; |
|
217 |
+ |
} |
|
218 |
+ |
} |
|
219 |
+ |
|
194 |
220 |
|
public void NotifyPropertyChanged(string propertyName) |
195 |
221 |
|
{ |
196 |
222 |
|
if (PropertyChanged != null) |