Esempio n. 1
0
        protected async Task MapLoaded()
        {
            Logger.LogDebug("map loaded");
            Loading = false;

            var bounds = await bingMap.GetBoundsAsync();

            _polyLine = new BingMapPolyline
            {
                Coordinates = new BindingList <Location>
                {
                    new Location(bounds.Center.Latitude + bounds.Height / 3f, bounds.Center.Longitude - bounds.Width / 3f),
                    new Location(bounds.Center.Latitude, bounds.Center.Longitude),
                    new Location(bounds.Center.Latitude + bounds.Height / 3f, bounds.Center.Longitude + bounds.Width / 3f),
                },
                Options = new BingMapPolylineOptions
                {
                    StrokeColor     = Color.FromSystemColor(System.Drawing.Color.Red),
                    StrokeThickness = 3,
                    StrokeDashArray = new int[] { 3, 3, 0, 2 }
                }
            };

            _polyLine.OnClick       += PolyLine_OnClick;
            _polyLine.OnDoubleClick += PolyLine_OnDoubleClick;
            _polyLine.OnMouseDown   += PolyLine_OnMouseDown;
            _polyLine.OnMouseOut    += PolyLine_OnMouseOut;
            _polyLine.OnMouseOver   += PolyLine_OnMouseOver;
            _polyLine.OnMouseUp     += PolyLine_OnMouseUp;

            Entities.Add(_polyLine);

            _changePolylineTimer = new Timer(async(o) =>
            {
                var newBounds = await bingMap.GetBoundsAsync();
                var latitude  = newBounds.Center.Latitude;
                var longitude = newBounds.Center.Longitude - newBounds.Height / 4f;

                _polyLine.Coordinates.Insert(1, new Location(latitude, longitude));
                StateHasChanged();
            }, null, 3000, Timeout.Infinite);

            StateHasChanged();
        }