Exemplo n.º 1
0
        private void RoutesListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var lb = sender as ListBox;

            if (lb == null || lb.SelectedIndex < 0)
            {
                return;
            }
            var selectedRoute = lb.SelectedItem as BotRoute;

            if (selectedRoute == null)
            {
                return;
            }
            ClearRouteBuilder();
            var start = true;

            foreach (var wp in selectedRoute.InitialWp)
            {
                CreateNewMarker(new PointLatLng(wp.Latitude, wp.Longitude), start);
                if (start)
                {
                    start = false;
                }
            }
            RouteCreatorMap.ZoomAndCenterMarkers(null);
        }
        private void RoutesListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var lb = sender as ListBox;

            if (lb == null || lb.SelectedIndex < 0)
            {
                return;
            }
            var selectedRoute = lb.SelectedItem as BotRoute;

            if (selectedRoute == null)
            {
                return;
            }
            ClearRouteBuilder();
            var start = true;

            foreach (var wp in selectedRoute.InitialWp)
            {
                CreateNewMarker(new PointLatLng(wp.Latitude, wp.Longitude), start);
                if (start)
                {
                    start = false;
                }
            }
            double dist;
            var    mid =
                HeatMapHelper.GetMidPointAndRadius(
                    selectedRoute.InitialWp.Select(x => new PointLatLng(x.Latitude, x.Longitude)), out dist);

            RunDataTasks(mid, dist);
            RouteCreatorMap.ZoomAndCenterMarkers(null);
        }
Exemplo n.º 3
0
        private void CreateNewMarker(Point point, bool starter)
        {
            _builded = false;
            var rPoint = point;
            var mapPos = RouteCreatorMap.FromLocalToLatLng((int)rPoint.X, (int)rPoint.Y);

            CreateNewMarker(mapPos, starter);
        }
        private void ImportRouteSubmit_Click(object sender, RoutedEventArgs e)
        {
            ImportExportRoute.Visibility = Visibility.Collapsed;
            var encRoute = ImportExportRouteText.Text;

            if (encRoute == null)
            {
                return;
            }
            List <GoogleLocation> decodedPoints;

            try
            {
                decodedPoints = RoutingUtils.DecodePolyline(encRoute).ToList();
            }
            catch (Exception)
            {
                return;
            }
            ClearRouteBuilder();
            var i = 0;

            foreach (var point in decodedPoints)
            {
                var pointlatlon = new PointLatLng(point.lat, point.lng);
                CreateImportedMarker(pointlatlon, i == 0);
                i++;
            }
            if (i > 0)
            {
                try
                {
                    if (_routeBuilder != null && _routeBuilder.Status == TaskStatus.Running)
                    {
                        return;
                    }
                    _cts          = new CancellationTokenSource();
                    _routeBuilder = Task.Run(() => BuildTheRouteTask(Token), Token);
                }
                catch (Exception)
                {
                    //ignore
                }
            }
            ImportExportRouteText.Clear();
            var startMarker = decodedPoints.FirstOrDefault();

            if (startMarker != null)
            {
                RouteCreatorMap.Position = new PointLatLng(startMarker.lat, startMarker.lng);
            }
            RouteCreatorMap.ZoomAndCenterMarkers(null);
        }
        private void MapSearchBox_KeyDown(object sender, KeyEventArgs e)
        {
            var tb = sender as TextBox;

            if (tb == null)
            {
                return;
            }
            if (e.Key != Key.Enter)
            {
                return;
            }
            var searchText = tb.Text;

            if (!string.IsNullOrEmpty(searchText))
            {
                RouteCreatorMap.SetPositionByKeywords(searchText);
            }
        }