/// <summary>
        /// Clear map data
        /// </summary>
        private void ClearMapInfo()
        {
            TrackPositions.Clear();

            if (MainMap.Children.Contains(_pinStart))
            {
                MainMap.Children.Remove(_pinStart);
            }
            if (MainMap.Children.Contains(_pinEnd))
            {
                MainMap.Children.Remove(_pinEnd);
            }
            if (MainMap.Children.Contains(_pinCar))
            {
                MainMap.Children.Remove(_pinCar);
            }

            foreach (var pin in OsrmWayPointsPushpins)
            {
                if (MainMap.Children.Contains(pin))
                {
                    MainMap.Children.Remove(pin);
                }
            }

            OsrmWayPointsPushpins?.Clear();
            MapPolyline.Locations?.Clear();
        }
        /// <summary>
        /// Delete point
        /// </summary>
        private void DeleteWayPointPushpin()
        {
            if (WayPointsForOsrmDataGrid.SelectedIndex != -1)
            {
                int tmpLastSelectedIndex = WayPointsForOsrmDataGrid.SelectedIndex;

                var pin = OsrmWayPointsPushpins[WayPointsForOsrmDataGrid.SelectedIndex];

                if (MainMap.Children.Contains(pin))
                {
                    MainMap.Children.Remove(pin);
                }

                OsrmWayPointsPushpins.RemoveAt(WayPointsForOsrmDataGrid.SelectedIndex);

                SetPushinsEnumaration(OsrmWayPointsPushpins);

                if (tmpLastSelectedIndex <= WayPointsForOsrmDataGrid.Items.Count - 1)
                {
                    WayPointsForOsrmDataGrid.SelectRowByIndex(tmpLastSelectedIndex);
                }
                else if (tmpLastSelectedIndex - 1 >= 0)
                {
                    WayPointsForOsrmDataGrid.SelectRowByIndex(tmpLastSelectedIndex - 1);
                }
            }
        }
        /// <summary>
        /// Marker click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Pin_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var pin = sender as DraggablePin;

            if (pin != null)
            {
                var index = OsrmWayPointsPushpins.IndexOf(pin);
                WayPointsForOsrmDataGrid.SelectRowByIndex(index);

                if (WayPointsForOsrmDataGrid.SelectedIndex >= 0)
                {
                    SetSelectedPushpinBackground(Color.FromRgb(37, 195, 50), WayPointsForOsrmDataGrid.SelectedIndex, OsrmWayPointsPushpins);
                }

                Keyboard.Focus(pin);
            }
        }
        /// <summary>
        /// Build a route based on Osrm
        /// </summary>
        /// <returns></returns>
        private async Task GetLoadOsrmTrack()
        {
            try
            {
                MapPolyline.Locations?.Clear(); // Delete the current route

                var trackPositions =
                    OsrmWayPointsPushpins.Select(
                        point => new TrackPosition {
                    Latitude = point.Location.Latitude, Longitude = point.Location.Longitude
                })
                    .ToArray();

                await GetDataFromOsrm(trackPositions);
            }
            catch (Exception exc)
            {
                LogWindowControl.AddMessage(exc.Message);
            }
        }
        /// <summary>
        /// Double-click to add a marker to the map to build a route
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void MainMap_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            // Disables the default mouse double-click action.
            e.Handled = true;

            //Get the mouse click coordinates
            Point mousePosition = e.GetPosition(MainMap);
            //Convert the mouse coordinates to a locatoin on the map
            Location pinLocation = MainMap.ViewportPointToLocation(mousePosition);

            // The pushpin to add to the map.
            DraggablePin pin = new DraggablePin(MainMap)
            {
                Background = new SolidColorBrush(Color.FromRgb(58, 74, 216)),
                Foreground = new SolidColorBrush(Colors.White),
                Location   = pinLocation,
                Content    = OsrmWayPointsPushpins.Count + 1
            };

            if (_wayPointsEditModeEnabled && WayPointsForOsrmDataGrid.SelectedIndex >= 0)
            {
                OsrmWayPointsPushpins.Insert(WayPointsForOsrmDataGrid.SelectedIndex + 1, pin);
                SetPushinsEnumaration(OsrmWayPointsPushpins);
                WayPointsForOsrmDataGrid.SelectRowByIndex(WayPointsForOsrmDataGrid.SelectedIndex + 1);
            }
            else
            {
                OsrmWayPointsPushpins.Add(pin);
            }

            pin.MouseDown += Pin_MouseDown;

            MainMap.Children.Add(pin);

            if (AutoRouteDrowCheckBox.IsChecked != null && AutoRouteDrowCheckBox.IsChecked == true)
            {
                await GetLoadOsrmTrack();
            }

            CheckTabItems();
        }