protected async Task MapLoaded() { Loading = false; var bounds = await bingMap.GetBoundsAsync(); var latitude = bounds.Center.Latitude; var longitude = bounds.Center.Longitude; polygon = new BingMapPolygon { Coordinates = new BindingList <Geocoordinate> { new Geocoordinate { Latitude = latitude + 0.1, Longitude = longitude - 0.1 }, new Geocoordinate { Latitude = latitude + 0.1, Longitude = longitude + 0.1 }, new Geocoordinate { Latitude = latitude - 0.1, Longitude = longitude + 0.1 }, new Geocoordinate { Latitude = latitude - 0.1, Longitude = longitude - 0.1 } }, Options = new BingMapPolygonOptions { FillColor = Color.FromArgb(0x7F, Color.Blue), StrokeThickness = 2, StrokeColor = Color.Red } }; polygon.OnClick += Polygon_OnClick; polygon.OnDoubleClick += Polygon_OnDoubleClick; polygon.OnMouseDown += Polygon_OnMouseDown; polygon.OnMouseOut += Polygon_OnMouseOut; polygon.OnMouseOver += Polygon_OnMouseOver; polygon.OnMouseUp += Polygon_OnMouseUp; Entities.Add(polygon); changePolygonTimer = new Timer(async o => { bounds = await bingMap.GetBoundsAsync(); latitude = bounds.Center.Latitude; longitude = bounds.Center.Longitude; polygon.Rings = new BindingList <Geocoordinate[]> { new Geocoordinate[] { new Geocoordinate { Latitude = latitude + 0.1, Longitude = longitude - 0.1 }, new Geocoordinate { Latitude = latitude + 0.1, Longitude = longitude + 0.1 }, new Geocoordinate { Latitude = latitude - 0.1, Longitude = longitude + 0.1 }, new Geocoordinate { Latitude = latitude - 0.1, Longitude = longitude - 0.1 } }, new Geocoordinate[] { new Geocoordinate { Latitude = latitude + 0.05, Longitude = longitude - 0.05 }, new Geocoordinate { Latitude = latitude - 0.05, Longitude = longitude - 0.05 }, new Geocoordinate { Latitude = latitude - 0.05, Longitude = longitude + 0.05 }, new Geocoordinate { Latitude = latitude + 0.05, Longitude = longitude + 0.05 } } }; StateHasChanged(); }, null, 3000, Timeout.Infinite); }
protected async Task MapLoaded() { Logger.LogDebug("map loaded"); Loading = false; var bounds = await bingMap.GetBoundsAsync(); var latitude = bounds.Center.Latitude; var longitude = bounds.Center.Longitude; _polygon = new BingMapPolygon { Coordinates = new BindingList <Geocoordinate> { new Geocoordinate { Latitude = latitude + 0.1, Longitude = longitude - 0.1 }, new Geocoordinate { Latitude = latitude + 0.1, Longitude = longitude + 0.1 }, new Geocoordinate { Latitude = latitude - 0.1, Longitude = longitude + 0.1 }, new Geocoordinate { Latitude = latitude - 0.1, Longitude = longitude - 0.1 } }, Options = new BingMapPolygonOptions { FillColor = Color.FromSystemColor(System.Drawing.Color.FromArgb(0x7F, System.Drawing.Color.Blue)), StrokeThickness = 2, StrokeColor = Color.FromSystemColor(System.Drawing.Color.Red) } }; _polygon.OnClick += Polygon_OnClick; _polygon.OnDoubleClick += Polygon_OnDoubleClick; _polygon.OnMouseDown += Polygon_OnMouseDown; _polygon.OnMouseOut += Polygon_OnMouseOut; _polygon.OnMouseOver += Polygon_OnMouseOver; _polygon.OnMouseUp += Polygon_OnMouseUp; var coords = JsonSerializer.Serialize(_polygon.Coordinates); var rings = JsonSerializer.Serialize(_polygon.Rings); var a = JsonSerializer.Serialize(_polygon.Options.FillColor); var b = JsonSerializer.Serialize(_polygon.OptionsSnapshot); var c = JsonSerializer.Serialize(_polygon.Metadata); Entities.Add(_polygon); _changePolygonTimer = new Timer(async o => { bounds = await bingMap.GetBoundsAsync(); latitude = bounds.Center.Latitude; longitude = bounds.Center.Longitude; _polygon.Rings = new BindingList <Geocoordinate[]> { new Geocoordinate[] { new Geocoordinate { Latitude = latitude + 0.1, Longitude = longitude - 0.1 }, new Geocoordinate { Latitude = latitude + 0.1, Longitude = longitude + 0.1 }, new Geocoordinate { Latitude = latitude - 0.1, Longitude = longitude + 0.1 }, new Geocoordinate { Latitude = latitude - 0.1, Longitude = longitude - 0.1 } }, new Geocoordinate[] { new Geocoordinate { Latitude = latitude + 0.05, Longitude = longitude - 0.05 }, new Geocoordinate { Latitude = latitude - 0.05, Longitude = longitude - 0.05 }, new Geocoordinate { Latitude = latitude - 0.05, Longitude = longitude + 0.05 }, new Geocoordinate { Latitude = latitude + 0.05, Longitude = longitude + 0.05 } } }; StateHasChanged(); }, null, 3000, Timeout.Infinite); }