public MyMarkerRedAnchor(MyMapControl window, GMapMarker marker, string title, params object[] viewModels) { InitializeComponent(); this.MainWindow = window; this.Marker = marker; Popup = new Popup(); //Label = new Label(); this.MouseLeftButtonUp += new MouseButtonEventHandler(CustomMarkerDemo_MouseLeftButtonUp); this.MouseLeftButtonDown += new MouseButtonEventHandler(CustomMarkerDemo_MouseLeftButtonDown); this.MouseMove += new MouseEventHandler(CustomMarkerDemo_MouseMove); this.MouseLeave += new MouseEventHandler(MarkerControl_MouseLeave); this.MouseEnter += new MouseEventHandler(MarkerControl_MouseEnter); Popup.Placement = PlacementMode.Mouse; //{ // Label.Background = Brushes.Blue; // Label.Foreground = Brushes.White; // Label.BorderBrush = Brushes.WhiteSmoke; // Label.BorderThickness = new Thickness(2); // Label.Padding = new Thickness(5); // Label.FontSize = 16; // Label.Content = title; //} Popup.Child = new MyMarkerRedAnchorDepict();// Label; }
public MyMarkerRouteAnchor(MyMapControl window, GMapMarker marker, string title) { InitializeComponent(); this.MainWindow = window; this.Marker = marker; Popup = new Popup(); Label = new Label(); this.Unloaded += new RoutedEventHandler(CustomMarkerDemo_Unloaded); this.Loaded += new RoutedEventHandler(CustomMarkerDemo_Loaded); this.SizeChanged += new SizeChangedEventHandler(CustomMarkerDemo_SizeChanged); this.MouseEnter += new MouseEventHandler(MarkerControl_MouseEnter); this.MouseLeave += new MouseEventHandler(MarkerControl_MouseLeave); //this.MouseMove += new MouseEventHandler(CustomMarkerDemo_MouseMove);// mouse drag move Popup.Placement = PlacementMode.Mouse; { Label.Background = Brushes.Purple; Label.Foreground = Brushes.White; Label.BorderBrush = Brushes.WhiteSmoke; Label.BorderThickness = new Thickness(2); Label.Padding = new Thickness(5); Label.FontSize = 13; Label.Content = title; } Popup.Child = Label; }
/// <summary> /// Zooms map to current selection. /// </summary> private void ZoomToSelection() { // Get dictionary of bounds from API IDictionary <string, PostGisPoint> bounds = new ApiHandler.ApiHandler().GetBounds().ToDictionary(pair => pair.Key, pair => pair.Value); // Ensure that bounds exist if (!bounds.TryGetValue("top_left", out PostGisPoint topLeft) || !bounds.TryGetValue("bottom_right", out PostGisPoint botRight)) { // TODO : Add some sort of error return; } BoundTopLeft = topLeft; BoundBottomRight = botRight; // Calculate the center point Geopoint centerGeopoint = new Geopoint(new BasicGeoposition { Latitude = ((BoundTopLeft.Latitude - BoundBottomRight.Latitude) / 2) + BoundBottomRight.Latitude, Longitude = ((BoundBottomRight.Longitude - BoundTopLeft.Longitude) / 2) + BoundTopLeft.Longitude }); // Set viewport to bounds MyMapControl.TrySetViewAsync(centerGeopoint, 16); }
public MapPage() { InitializeComponent(); MyMapControl.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(55.652397, 12.139755), Distance.FromKilometers(0.5))); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed LocationPermission(); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }
/// <summary> /// Zooms map to current selection. /// </summary> private void ZoomToSelection() { // Calculate the center point Geopoint centerGeopoint = new Geopoint(new BasicGeoposition { Latitude = 43.1927816, Longitude = -80.3851837 }); // Set viewport to bounds MyMapControl.TrySetViewAsync(centerGeopoint, 16); }
private void ReloadMap(object sender, SelectionChangedEventArgs e) { MyMapControl.Map.Layers.Clear(); MyMapControl.Map = _Model.Map; MyMapControl.Refresh(); }
private void questTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { if (skipnextrecenter) { skipnextrecenter = false; return; } if (e.NewValue == null) { return; } if (e.NewValue.GetType() != typeof(QuestViewModel)) { return; } Quest selected = ((QuestViewModel)e.NewValue).correspondingQuest; if (selected.Deferred) { questTree.ContextMenu = questTree.Resources["Deferred"] as System.Windows.Controls.ContextMenu; } else { questTree.ContextMenu = questTree.Resources["Undeferred"] as System.Windows.Controls.ContextMenu; } if (selected.DiscoverPrompt == null) { if (CircleLayer != null) { CircleLayer.Enabled = false; circleShownOnLocation = null; } if (currentLocation != ShortNameLookup[selected.World]) { WorldSelectIndex = ShortNames.IndexOf(ShortNameLookup[selected.World]); } return; } if (selected.DiscoverPrompt.DiscoverPosition != null) { if (CircleLayer != null) { CircleLayer.Enabled = true; } if (currentLocation != ShortNameLookup[selected.DiscoverPrompt.DiscoverPosition.World]) { WorldSelectIndex = ShortNames.IndexOf(ShortNameLookup[selected.DiscoverPrompt.DiscoverPosition.World]); } CenterMap(selected.DiscoverPrompt.DiscoverPosition.X, selected.DiscoverPrompt.DiscoverPosition.Y); AddCircleAt(new Mapsui.Geometries.Point(selected.DiscoverPrompt.DiscoverPosition.X, selected.DiscoverPrompt.DiscoverPosition.Y)); MyMapControl.Refresh(); } else { if (CircleLayer != null) { CircleLayer.Enabled = false; circleShownOnLocation = null; } } if (selected.DiscoverPrompt.Info != "") { InfoMessage = selected.DiscoverPrompt.Info; } }
private void ToggleLayers() { MyMapControl.Refresh(); }
private void LoadMap(string location) { ObservableCollection <MarkerViewModel> tempmarkers = new ObservableCollection <MarkerViewModel>(); MarkerViewModel root; bool worldWasAlreadyLoaded = MarkersPerWorld.ContainsKey(location); if (worldWasAlreadyLoaded) { root = MarkersPerWorld[location]; } else { root = MarkerViewModel.CreateRoot(Path.Combine(appdir, smalliconpath)); MarkersPerWorld.Add(location, root); } currentLocation = location; CurrentConvertor = ConversionLibrary[location]; if (tileLayer != null) { //fixes memory leak in Mapsui tileLayer.AbortFetch(); MyMapControl.Map.Layers.Clear(); } MbTilesTileSource _source = new MbTilesTileSource(new SQLiteConnectionString(PathLibrary[location], false)); tileLayer = new Mapsui.Layers.TileLayerAbort(_source); MyMapControl.Map.Layers.Add(tileLayer); Dictionary <MapPinType, MapPinCollection> worldpindata = mappindata.GetPins(ShortNameLookup[location]); foreach (MapPinType pintype in worldpindata.Keys) { //I want to do this last if (pintype.InternalName == "RoadSign") { continue; } if (worldWasAlreadyLoaded) { MyMapControl.Map.Layers.Add(root.FindChild(pintype.InternalName).AssociatedLayer); continue; } Mapsui.Layers.MemoryLayer _pointlayer = new Mapsui.Layers.MemoryLayer { Style = null }; List <Mapsui.Geometries.Point> _points = new List <Mapsui.Geometries.Point>(); string path = Path.Combine(appdir, largeiconpath, pintype.IconFile); //Load the image if needed if (!IconCache.ContainsKey(path)) { using (FileStream fs = new FileStream(path, FileMode.Open)) { MemoryStream ms = new MemoryStream(); fs.CopyTo(ms); int id = BitmapRegistry.Instance.Register(ms); IconCache[path] = id; } } if (pintype.InternalName.Contains("Quest")) { foreach (MapPin c in worldpindata[pintype].Locations) { //Try to match Pin coords and Quest coords Quest q = progressStatus.getQuestByCoordinates(Convert.ToInt32(c.Location.X), Convert.ToInt32(c.Location.Y)); //If no matching quest found then still display the Pin bool questNotDoneOrNotFound = q == null || !q.Done; if (questNotDoneOrNotFound) { _points.Add(CurrentConvertor.ToWorldSpace(c.Location)); } } } else { foreach (MapPin c in worldpindata[pintype].Locations) { _points.Add(CurrentConvertor.ToWorldSpace(c.Location)); } } _pointlayer.DataSource = new Mapsui.Providers.MemoryProvider(_points); SymbolStyle _style = new SymbolStyle(); _style.BitmapId = IconCache[path]; _pointlayer.Style = _style; _pointlayer.Name = pintype.Name; MyMapControl.Map.Layers.Add(_pointlayer); root.AddChild(new MarkerViewModel(pintype, _pointlayer)); } root.VerifyCheckState(); AddCircleLayer(); //Add label layer last so that it's on top MyMapControl.Map.Layers.Add(GetLabelLayer(worldpindata)); MyMapControl.Map.BackColor = new Color(184, 222, 230); tempmarkers.Add(root); _markers = tempmarkers; RaisePropertyChanged("Markers"); if (RandomPlayersOnMap) { ToggleGwentPlayers(true); } else { MarkerViewModel gw = Markers[0].FindChild("GwentPlayer"); if (gw != null) { gw.IsChecked = false; } } MyMapControl.Refresh(); }
private void Button_Click(object sender, RoutedEventArgs e) { MyMapControl.ZoomIn(); }