async void SetUserTrackCurrentLocation(double latitude, double longitude) { try { CloseMessage(); // trvMap.Children.Clear(); // Get the cancellation token. _cts = new CancellationTokenSource(); token = _cts.Token; // Get the location. Location location = new Location(latitude, longitude); //// Now set the zoom level of the map based on the accuracy of our location data. //// Default to IP level accuracy. We only show the region at this level - No icon is displayed. //double zoomLevel = 13.0f; //// Add the 10m icon and zoom closer. //if (trvMap.Children.Count == 0) { // trvMap.Children.Add(_locationIcon10m); //} //MapLayer.SetPosition(_locationIcon10m, location); //zoomLevel = 15.0f; //// Set the map to the given location and zoom level. //trvMap.SetView(location, zoomLevel); // Now set the zoom level of the map based on the accuracy of our location data. // Default to IP level accuracy. We only show the region at this level - No icon is displayed. double zoomLevel = 17.0f; LocationIcon10m _locationUserIcon10m = new LocationIcon10m(); Callout callout = new Callout(); callout.Text = "Tracker's Location"; callout.Lon = "Lon (λ): " + location.Longitude.ToString().Substring(0, 7); callout.Lat = "Lat (φ): " + location.Latitude.ToString().Substring(0, 7); _locationUserIcon10m.DataContext = callout; foreach (var children in trvMap.Children) { if (children.GetType().Name == "LocationIcon10m") { trvMap.Children.Remove(children); break; } } // Add the 10m icon and zoom closer. trvMap.Children.Add(_locationUserIcon10m); MapLayer.SetPosition(_locationUserIcon10m, location); // Set the map to the given location and zoom level. trvMap.SetView(location, zoomLevel); } catch { } }
public TrackMap() { this.InitializeComponent(); _geolocator = new Geolocator(); _locationIcon10m = new LocationIcon10m(); _locationIcon100m = new LocationIcon100m(); if (myTimer != null) { myTimer.Stop(); } if (trackerTimer != null) { trackerTimer.Stop(); } MapCurrentLocation(); AddDeactivateAccountMenu(); }