private void mapView_Loaded(object sender, RoutedEventArgs e) { telemetry.tel_update(Convert.ToDouble(ConfigurationManager.AppSettings["init_lat"]), Convert.ToDouble(ConfigurationManager.AppSettings["init_lng"])); GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache; mapView.CacheLocation = @"C:\cache\"; // choose your provider here mapView.MapProvider = GMap.NET.MapProviders.OpenStreetMapProvider.Instance; mapView.MinZoom = 2; mapView.MaxZoom = 22; mapView.ShowCenter = false; // whole world zoom mapView.Position = new GMap.NET.PointLatLng(telemetry.LAT, telemetry.LNG); mapView.Zoom = 15; // lets the map use the mousewheel to zoom mapView.MouseWheelZoomType = GMap.NET.MouseWheelZoomType.MousePositionAndCenter; // lets the user drag the map mapView.CanDragMap = true; // lets the user drag the map with the left mouse button mapView.DragButton = MouseButton.Left; var own_pos = new GMap.NET.WindowsPresentation.GMapMarker(new GMap.NET.PointLatLng(telemetry.LAT, telemetry.LNG)); own_pos.Shape = new Ellipse { Width = 20, Height = 20, Stroke = System.Windows.Media.Brushes.Black, StrokeThickness = 4 }; mapView.Markers.Add(own_pos); }
private void btnTraceDevices_Click(object sender, RoutedEventArgs e) { try { firebaseClient = new FireSharp.FirebaseClient(config); if (String.IsNullOrWhiteSpace(cmbIssueCountry.Text) || String.IsNullOrWhiteSpace(cmbIssueCity.Text) || String.IsNullOrWhiteSpace(txtDeviceID.Text)) { MessageBox.Show("A required field was not filled", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { deviceCode = countryCode + cityCode + txtDeviceID.Text; //Generating device code using concatenation of countryCode, cityCode and deviceID. FirebaseResponse firebaseResponse = firebaseClient.Get(cmbIssueCountry.SelectedItem.ToString() + "/" + cmbIssueCity.SelectedItem.ToString() + "/" + deviceCode); LatLong location = firebaseResponse.ResultAs <LatLong>(); // DB Result PointLatLng loc = new PointLatLng(location.Latitude, location.Longitude); System.Windows.Media.Imaging.BitmapImage bitmapImage = new System.Windows.Media.Imaging.BitmapImage(); bitmapImage.BeginInit(); if (cmbIssueCountry.SelectedItem.ToString() == "Turkey") { bitmapImage.UriSource = new Uri(@"C:\Users\YasinEmir\source\repos\Forensic\Forensic\TurkishFlag.png"); } else if (cmbIssueCountry.SelectedItem.ToString() == "United Kingdom") { bitmapImage.UriSource = new Uri(@"C:\Users\YasinEmir\source\repos\Forensic\Forensic\BritishFlag.png"); } else if (cmbIssueCountry.SelectedItem.ToString() == "Germany") { bitmapImage.UriSource = new Uri(@"C:\Users\YasinEmir\source\repos\Forensic\Forensic\GermanFlag.png"); } else if (cmbIssueCountry.SelectedItem.ToString() == "France") { bitmapImage.UriSource = new Uri(@"C:\Users\YasinEmir\source\repos\Forensic\Forensic\FrenchFlag.png"); } else if (cmbIssueCountry.SelectedItem.ToString() == "Spain") { bitmapImage.UriSource = new Uri(@"C:\Users\YasinEmir\source\repos\Forensic\Forensic\SpanishFlag.png"); } else if (cmbIssueCountry.SelectedItem.ToString() == "Italy") { bitmapImage.UriSource = new Uri(@"C:\Users\YasinEmir\source\repos\Forensic\Forensic\ItalianFlag.png"); } bitmapImage.EndInit(); GMap.NET.WindowsPresentation.GMapMarker marker2 = new GMap.NET.WindowsPresentation.GMapMarker(loc); Image image = new Image(); image.Source = bitmapImage; marker2.Shape = image; Gmap.Markers.Add(marker2); } } catch { MessageBox.Show("Sorry, We could not find a device with this ID number", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void Update_map(object sender, EventArgs e) { mapView.Markers.Clear(); var own_pos = new GMap.NET.WindowsPresentation.GMapMarker(new GMap.NET.PointLatLng(telemetry.LAT, telemetry.LNG)); var home_pos = new GMap.NET.WindowsPresentation.GMapMarker(new GMap.NET.PointLatLng(telemetry.LAT_HOME, telemetry.LNG_HOME)); double direction = telemetry.heading; var myPolyline = new Polyline(); myPolyline.Stroke = System.Windows.Media.Brushes.Red; myPolyline.StrokeThickness = 2; PointCollection myPointCollection2 = new PointCollection(); myPointCollection2.Add(new System.Windows.Point(-10 - 10 * telemetry.vel / 1, -10 - 10 * telemetry.vel / 1)); myPointCollection2.Add(new System.Windows.Point(-10, -10)); myPointCollection2.Add(new System.Windows.Point(-10, 10)); myPointCollection2.Add(new System.Windows.Point(10, 10)); myPointCollection2.Add(new System.Windows.Point(10, -10)); myPointCollection2.Add(new System.Windows.Point(-10, -10)); myPolyline.Points = myPointCollection2; own_pos.Shape = myPolyline; own_pos.Shape.RenderTransform = new RotateTransform(direction + 45); home_pos.Shape = new System.Windows.Shapes.Rectangle { Width = 20, Height = 20, Stroke = System.Windows.Media.Brushes.Black, StrokeThickness = 4 }; mapView.Markers.Add(own_pos); mapView.Markers.Add(home_pos); }
private void updateTargetMarker(PointLatLngAlt target) { if (targetMarker == null) { targetMarker = new GMap.NET.WindowsPresentation.GMapMarker(target); targetMarker.Shape = new Ellipse { Width = 10, Height = 10, Stroke = Brushes.Red, StrokeThickness = 5 }; mapView.Markers.Add(targetMarker); } else { targetMarker.Position = target; } }
/// <summary> /// Draws the marker /// </summary> /// <param name="x">x coordinate</param> /// <param name="y">y coordinate</param> /// <param name="size">size of the marker</param> private void Draw(double x, double y, double size) { try { GMapMarker marker = new GMapMarker(new PointLatLng(x, y)) { Shape = new Ellipse { Width = size * 2.5, Height = size * 2.5, Stroke = Brushes.Red, Fill = Brushes.Black, StrokeThickness = 1.5, }, Offset = new Point(-size / 2, y: -size / 2) }; _markers.Add(marker); } catch (Exception ex) { Log(ex.Message + " | " + ex.StackTrace, "Error"); } }
private void Button_Click_2(object sender, RoutedEventArgs e) { closeMenuBar(); AdCanvas.Visibility = Visibility.Hidden; EditProfileCanvas.Visibility = Visibility.Hidden; BueydAdsCanvas.Visibility = Visibility.Hidden; VacanciesCanvas.Visibility = Visibility.Hidden; SummaryCanvas.Visibility = Visibility.Hidden; MapCanvas.Visibility = Visibility.Visible; gMapControl1.Bearing = 0; //Настройки для компонента GMap. gMapControl1.Bearing = 0; //CanDragMap - Если параметр установлен в True, //пользователь может перетаскивать карту ///с помощью правой кнопки мыши. gMapControl1.CanDragMap = true; //Указываем, что перетаскивание карты осуществляется //с использованием левой клавишей мыши. //По умолчанию - правая. gMapControl1.DragButton = MouseButton.Left; gMapControl1.ScaleMode = GMap.NET.WindowsPresentation.ScaleModes.Dynamic; gMapControl1.MouseWheelZoomEnabled = true; //MarkersEnabled - Если параметр установлен в True, //любые маркеры, заданные вручную будет показаны. //Если нет, они не появятся. //Указываем значение максимального приближения. gMapControl1.MaxZoom = 20; //Указываем значение минимального приближения. gMapControl1.MinZoom = 2; //Устанавливаем центр приближения/удаления //курсор мыши. gMapControl1.MouseWheelZoomType = GMap.NET.MouseWheelZoomType.MousePositionAndCenter; //gMapControl1.SetPositionByKeywords("Russia, Krasnoyarsk Krai, Krasnoyarsk"); gMapControl1.Position = new GMap.NET.PointLatLng(56.015514, 92.974354); GMap.NET.WindowsPresentation.GMapMarker marker = new GMap.NET.WindowsPresentation.GMapMarker(new GMap.NET.PointLatLng(56.015514, 92.974354)); marker.Tag = "marker"; Ellipse shape = new Ellipse { Width = 20, Height = 20, Fill = System.Windows.Media.Brushes.Green, Stroke = System.Windows.Media.Brushes.Green, StrokeThickness = 1.5, ToolTip = "Office 1" }; shape.MouseDown += Shape_MouseDown; marker.Shape = shape; gMapControl1.Markers.Add(marker); gMapControl1.ShowTileGridLines = false; gMapControl1.Zoom = 12.17; gMapControl1.MapProvider = GMap.NET.MapProviders.GMapProviders.GoogleMap; GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly; }