/********************************************************************** * Methods **********************************************************************/ public string BuildOutput() { string strRc = string.Empty; strRc = $"A {MyColor} {ShapeName} located at {MyCoordinates.BuildOutput()}"; return(strRc); }
/// <summary> /// Event handler for geocode query completed. /// </summary> /// <param name="e">Results of the geocode query - list of locations</param> private void GeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e) { HideProgressIndicator(); if (e.Error == null) { if (e.Result.Count > 0) { if (_isRouteSearch) // Query is made to locate the destination of a route { // Only store the destination for drawing the map markers MyCoordinates.Add(e.Result[0].GeoCoordinate); // Route from current location to first search result List <GeoCoordinate> routeCoordinates = new List <GeoCoordinate>(); routeCoordinates.Add(MyCoordinate); routeCoordinates.Add(e.Result[0].GeoCoordinate); CalculateRoute(routeCoordinates); } else // Query is made to search the map for a keyword { // Add all results to MyCoordinates for drawing the map markers. for (int i = 0; i < e.Result.Count; i++) { MyCoordinates.Add(e.Result[i].GeoCoordinate); } // Center on the first result. MyMap.SetView(e.Result[0].GeoCoordinate, 10, MapAnimationKind.Parabolic); } } else { MessageBox.Show(AppResources.NoMatchFoundMessageBoxText, AppResources.ApplicationTitle, MessageBoxButton.OK); } MyGeocodeQuery.Dispose(); } DrawMapMarkers(); }
/// <summary> /// Event handler for search input text box key down. /// </summary> private void SearchTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (SearchTextBox.Text.Length > 0) { // New query - Clear the map of markers and routes if (MyMapRoute != null) { MyMap.RemoveRoute(MyMapRoute); } MyCoordinates.Clear(); DrawMapMarkers(); HideDirections(); AppBarDirectionsMenuItem.IsEnabled = false; SearchForTerm(SearchTextBox.Text); this.Focus(); } } }
private async void GetCoordinates() { // Get the phone's current location. Geolocator MyGeolocator = new Geolocator(); MyGeolocator.DesiredAccuracyInMeters = 1; Geoposition MyGeoPosition = null; try { MyGeoPosition = await MyGeolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10)); MyCoordinates.Add(new GeoCoordinate(MyGeoPosition.Coordinate.Point.Position.Latitude, MyGeoPosition.Coordinate.Point.Position.Longitude)); } catch (UnauthorizedAccessException) { MessageBox.Show("Location is disabled in phone settings or capabilities are not checked."); } catch (Exception ex) { // Something else happened while acquiring the location. MessageBox.Show(ex.Message); } }
internal MyMap(string sname, MyCoordinates scoordinates, double smyscale) { MapName = sname; coordinates = scoordinates; mapScale = smyscale; }