protected async Task MapLoaded() { 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 { 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(); }
public async Task AddPushpin() { var bounds = await bingMap.GetBoundsAsync(); var pushpins = await DevToolService.GetPushpins(3, bounds, new PushpinOptions { Draggable = true, Icon = "https://www.bingmapsportal.com/Content/images/poi_custom.png" }); pushpins.ForEach(pushpin => { index++; pushpin.Id = index.ToString(); pushpin.Options.Text = index.ToString(); pushpin.OnMouseOver += Pushpin_OnMouseOver; pushpin.OnMouseOut += Pushpin_OnMouseOut; pushpin.OnDragEnd += Pushpin_OnDragEnd; pushpin.OnDragStart += Pushpin_OnDragStart; }); Entities.AddRange(pushpins); }
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); }