/// <summary>
        /// Handles clicks to set waypoint as destination
        /// </summary>
        private void SetArrivalWaypoint_Click(object sender, RoutedEventArgs e)
        {
            var location = ((MenuFlyoutItem)sender).DataContext as LocationData;

            RouteWaypoints.Add(location);
            RouteDirectionSplitView.IsPaneOpen = true;
        }
        /// <summary>
        /// Handles clicks to the Show Route button and display
        /// the route to the selected location from the user's current position.
        /// </summary>
        private void ShowRouteButton_Click(object sender, RoutedEventArgs e)
        {
            var location = GetLocation(sender as Button);

            RouteWaypoints.Clear();
            RouteWaypoints.Insert(0, MappedLocations[0]);
            RouteWaypoints.Add(location);

            RouteDirectionSplitView.IsPaneOpen = true;
        }
        private void searchBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
        {
            string tag = ((AutoSuggestBox)sender).Tag.ToString();

            var selected = args.SelectedItem as Result;

            LocationData location = new LocationData()
            {
                Position = new BasicGeoposition()
                {
                    Latitude = selected.position.lat, Longitude = selected.position.lon, Altitude = 50
                }
            };

            location.Name             = LocationHelper.ConstructStringFromAddress(selected.address, "name", null);
            location.Address          = LocationHelper.ConstructStringFromAddress(selected.address, "address", null);
            location.FormattedAddress = LocationHelper.ConstructStringFromAddress(selected.address, "full", null);

            if (String.IsNullOrWhiteSpace(location.Name))
            {
                location.Name = selected.position.lat.ToString("0.000000, ") + selected.position.lon.ToString("0.000000");
            }

            if (selected.poi != null)
            {
                location.Name = selected.poi.name;
            }

            EditNewLocation(location);

            if (tag == "main")
            {
                mainSearchBox.Text = string.Empty;
            }
            else
            {
                RouteWaypoints.Add(location);
                WayPointSearch.Text                   = string.Empty;
                AddRouteWayPointGrid.Visibility       = Visibility.Collapsed;
                AddRouteWayPointButtonGrid.Visibility = Visibility.Visible;
            }
        }