private void UxMap_OnLoaded(object sender, RoutedEventArgs e) { var map = sender as Bing.Maps.Map; map.Center = new Location(Item.Latitude, Item.Longtitude); var pushpin = new Bing.Maps.Pushpin(); MapLayer.SetPosition(pushpin, map.Center); map.Children.Add(pushpin); }
void MyMap_PointerPressedOverride(object sender, PointerRoutedEventArgs e) { Bing.Maps.Location l = new Bing.Maps.Location(); this.MapPlace.TryPixelToLocation(e.GetCurrentPoint(this.MapPlace).Position, out l); Bing.Maps.Pushpin pushpin = new Bing.Maps.Pushpin(); pushpin.SetValue(Bing.Maps.MapLayer.PositionProperty, l); this.MapPlace.Children.Add(pushpin); var rmain = ServiceLocator.Current.GetInstance <MainViewModel>(); ///rmain.MyCoordinate = new Geoposition(); rmain.Latitude = l.Latitude; rmain.Longitude = l.Longitude; rmain.UpdateDistances(); rmain.GetNearestItems(); }
private async void OnLocatorPositionChanged(Geolocator sender, PositionChangedEventArgs args) { DefaultViewModel["Coordinate"] = args.Position.Coordinate; await MapControl.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { MapControl.Center = new Bing.Maps.Location { Longitude = args.Position.Coordinate.Point.Position.Longitude, Latitude = args.Position.Coordinate.Point.Position.Latitude, }; Pushpin pin = new Bing.Maps.Pushpin(); pin.SetValue(Bing.Maps.MapLayer.PositionProperty, new Bing.Maps.Location(MapControl.Center)); MapControl.Children.Clear(); MapControl.Children.Add(pin); MapControl.SetZoomLevel(10, TimeSpan.FromSeconds(1)); }); }
private async Task fetchSpeedTraps() { SpeedTrapMap.Children.Clear(); //Clear all current entries from the map //TODO: Replace .Take(1000) with something that handles paging var items = await speedTrapLocationTable.Take(1000).ToListAsync(); foreach (var item in items) { var pushpin = new Bing.Maps.Pushpin(); Flyout f = new Flyout(); pushpin.PointerEntered += ((pinControl, ev) => { // Flyout is a ContentControl so set your content within it. f.Content = new SpeedTrap(item); f.Placement = PlacementMode.Top; f.PlacementTarget = (UIElement)pinControl; //Make it appear near the push pin element layoutRoot.Children.Add(f.HostPopup); f.Closed += (b, c) => { layoutRoot.Children.Remove(f.HostPopup); }; f.IsOpen = true; }); pushpin.PointerExited += ((s, ev) => { f.IsOpen = false; }); //This function orients the pushpin on the map before we add it to the map MapLayer.SetPosition(pushpin, new Location(item.Latitude, item.Longitude)); SpeedTrapMap.Children.Add((UIElement)pushpin); } }