Пример #1
0
        private async void DrawPolyline(List <BasicGeoposition> geopositions)
        {
            ActivityMap.MapElements.Clear();

            if (geopositions.Any())
            {
                var polyLine = new MapPolyline {
                    Path = new Geopath(geopositions), StrokeThickness = 4, StrokeColor = (Color)App.Current.Resources["StravaRedColor"]
                };
                ActivityMap.MapElements.Add(polyLine);

                MapIcon startMapIcon = new MapIcon();
                startMapIcon.Location = new Geopoint(geopositions.First());
                startMapIcon.NormalizedAnchorPoint = new Point(0.5, 0.5);
                startMapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Start.png"));
                ActivityMap.MapElements.Add(startMapIcon);

                MapIcon endMapIcon = new MapIcon();
                endMapIcon.Location = new Geopoint(geopositions.Last());
                endMapIcon.NormalizedAnchorPoint = new Point(0.5, 0.5);
                endMapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/End.png"));
                ActivityMap.MapElements.Add(endMapIcon);

                var zoomed = false;
                while (!zoomed)
                {
                    zoomed = await ActivityMap.TrySetViewBoundsAsync(GeoboundingBox.TryCompute(geopositions), null, MapAnimationKind.None);
                }
            }
        }
Пример #2
0
        private void MainMap_Drop(object sender, DragEventArgs e)
        {
            if (OrgInfo != null)
            {
                Point      scpoint         = e.GetPosition(this);
                MapPointEx currentmappoint = ActivityMap.ShowMap.MainMap.ScreenToMap(new PointEx(scpoint.X, scpoint.Y));
                string     placeid         = ActivityMap.GetMouseLocationPlaceID(currentmappoint.X, currentmappoint.Y);
                if (string.IsNullOrEmpty(placeid))
                {
                    MessageBoxResult msgresult = MessageBox.Show("当前地点不是活动区域,是否手动选择地点?", "提示", MessageBoxButton.YesNo);
                    if (msgresult == MessageBoxResult.Yes)
                    {
                        SelectPlaceDialog selectplace = new SelectPlaceDialog();
                        selectplace.WindowStartupLocation     = WindowStartupLocation.CenterScreen;
                        selectplace.SelectedPlaceChangeEvent += (currentplaceId) =>
                        {
                            ActivityMap.CurrentPlaceId = currentplaceId;
                        };
                        selectplace.SelectedPlaceEvent += (placeguid) =>
                        {
                            placeid = placeguid;
                            ActivityMap.CurrentPlaceId = null;
                        };
                        selectplace.ShowDialog(this);
                    }
                }

                MapPlace place = ActivityMap.ShowMap.DrawElementList.FirstOrDefault(r => r.Key == OrgInfo.GUID).Value as MapPlace;
                if (place == null)
                {
                    place = new MapPlace();
                    place.BeforeDragPlaceEvent += OnBeforeDragPlace;
                    place.DeletePlaceEvent     += place_DeletePlaceEvent;
                }
                place.ORGinfo   = OrgInfo;
                place.PlaceGuid = placeid;
                place.MapPoint  = currentmappoint;

                SaveORGPLocation(placeid, currentmappoint);
                DrawORGToMap(place, currentmappoint);
            }
        }
Пример #3
0
        public async Task InitializeAsync()
        {
            ShowMapAndPolyline();

            await Task.Delay(1000);

            PopulateActivities();
            PopulateSegments();

            void ShowMapAndPolyline()
            {
                ActivityMap.Visual().Opacity = 0;
                ActivityMap.LoadingStatusChanged += ActivityMapLoadingStatusChanged;

                async void ActivityMapLoadingStatusChanged(MapControl sender, object args)
                {
                    ActivityMap.LoadingStatusChanged -= ActivityMapLoadingStatusChanged;
                    RemoveMapServiceTokenWarning();

                    ActivityMap.StartOpacityAnimation();
                    await DrawPolylineAsync();

                    AnimateMapProperties();

                    void RemoveMapServiceTokenWarning()
                    {
                        var mapGrid = ActivityMap.GetChildByName <Grid>("MapGrid");
                        var border  = mapGrid.Children().OfType <Border>().Last();

                        border.Visibility = Visibility.Collapsed;
                    }

                    void AnimateMapProperties()
                    {
                        ActivityMap.Animate(null, 45.0d, nameof(ActivityMap.Heading), 800, enableDependentAnimation: true);
                        ActivityMap.Animate(null, 75.0d, nameof(ActivityMap.DesiredPitch), 800, enableDependentAnimation: true);
                        ActivityMap.Animate(null, 14.5d, nameof(ActivityMap.ZoomLevel), 800, enableDependentAnimation: true);
                    }
                }
            }
        }
Пример #4
0
        private async Task DrawPolylineAsync()
        {
            var geoPositions = new List <BasicGeoposition>
            {
                new BasicGeoposition {
                    Latitude = -37.88385, Longitude = 145.18219
                },
                new BasicGeoposition {
                    Latitude = -37.88334, Longitude = 145.17769
                },
                new BasicGeoposition {
                    Latitude = -37.88385, Longitude = 145.17745
                },
                new BasicGeoposition {
                    Latitude = -37.88336, Longitude = 145.17674
                },
                new BasicGeoposition {
                    Latitude = -37.88268, Longitude = 145.17029
                },
                new BasicGeoposition {
                    Latitude = -37.88148, Longitude = 145.17013
                },
                new BasicGeoposition {
                    Latitude = -37.88081, Longitude = 145.16776
                },
                new BasicGeoposition {
                    Latitude = -37.88066, Longitude = 145.16563
                },
                new BasicGeoposition {
                    Latitude = -37.87992, Longitude = 145.16356
                }
            };

            var polyLine = new MapPolyline
            {
                Path            = new Geopath(geoPositions),
                StrokeThickness = 4,
                StrokeDashed    = false,
                StrokeColor     = Color.FromArgb(200, 245, 51, 39)
            };

            ActivityMap.MapElements.Add(polyLine);

            var startPoint = new Button {
                Style = (Style)App.Current.Resources["ButtonMapPointStyle"]
            };

            ActivityMap.Children.Add(startPoint);
            MapControl.SetLocation(startPoint, new Geopoint(geoPositions.First()));
            MapControl.SetNormalizedAnchorPoint(startPoint, new Point(0.5, 0.5));

            var endPoint = new Button {
                Style = (Style)App.Current.Resources["ButtonMapPinStyle"]
            };

            ActivityMap.Children.Add(endPoint);
            MapControl.SetLocation(endPoint, new Geopoint(geoPositions.Last()));
            MapControl.SetNormalizedAnchorPoint(endPoint, new Point(0.5, 0.5));

            var margin = ActualWidth / 4;
            await ActivityMap.TrySetViewBoundsAsync(GeoboundingBox.TryCompute(geoPositions),
                                                    new Thickness(margin, margin, margin, margin), MapAnimationKind.Bow);
        }