private void MapWithPolygon_MouseDoubleClick(object sender, MouseButtonEventArgs e) { e.Handled = true; // Creates a location for a single polygon point and adds it to // the polygon's point location list. Point mousePosition = e.GetPosition(this); //Convert the mouse coordinates to a location on the map Location polygonPointLocation = MapWithPolygon.ViewportPointToLocation(mousePosition); newPolygon.Locations.Add(polygonPointLocation); // A visual representation of a polygon point. Rectangle r = new Rectangle(); r.Fill = new SolidColorBrush(Colors.Red); r.Stroke = new SolidColorBrush(Colors.Yellow); r.StrokeThickness = 1; r.Width = 8; r.Height = 8; Pushpin pin = new Pushpin(); pin.Location = polygonPointLocation; // Adds the pushpin to the map. polygonPointLayer.Children.Add(pin); // Adds a small square where the user clicked, to mark the polygon point. polygonPointLayer.AddChild(r, polygonPointLocation); //Set focus back to the map so that +/- work for zoom in/out MapWithPolygon.Focus(); }
private void SetUpNewPolygon() { newPolygon = new MapPolygon(); // Defines the polygon fill details newPolygon.Locations = new LocationCollection(); newPolygon.Stroke = new SolidColorBrush(Colors.Green); newPolygon.StrokeThickness = 3; newPolygon.Opacity = 0.8; //Set focus back to the map so that +/- work for zoom in/out MapWithPolygon.Focus(); }
public MainWindow() { InitializeComponent(); //Set focus to map MapWithPolygon.Focus(); SetUpNewPolygon(); // Adds location points to the polygon for every single mouse click MapWithPolygon.MouseDoubleClick += new MouseButtonEventHandler(MapWithPolygon_MouseDoubleClick); // Adds the layer that contains the polygon points NewPolygonLayer.Children.Add(polygonPointLayer); MapWithPolygon.ViewChangeOnFrame += new EventHandler <MapEventArgs>(MyMap_ViewChangeOnFrame); }
public CreatePolygon() { InitializeComponent(); //Set focus to map MapWithPolygon.Focus(); SetUpNewPolygon(); // Adds location points to the polygon for every single mouse click MapWithPolygon.MouseDoubleClick += new MouseButtonEventHandler( MapWithPolygon_MouseDoubleClick); // Adds the layer that contains the polygon points NewPolygonLayer.Children.Add(polygonPointLayer); }
public MainWindow() { InitializeComponent(); // Focus the map on the center points MapWithPolygon.Focus(); LoadDataIntoChart(); // Display a console onscreen for debugging purposes //outputter = new ConsoleBoxHandler(TestBox); //Console.SetOut(outputter); //Console.WriteLine("Started"); // Add the layer of internet speeds to the TextLayer xaml layer TextLayer.Children.Add(labelLayer); WifiLayer.Children.Add(wifiLayer); }
private void SetupNewPolygon() // Run this to add a layer the postalcode heatmap { // Create a disposeable connection to the database to query against it using (SpeedApplicationDBEntities context = new SpeedApplicationDBEntities()) { foreach (var row in context.SpeedLocations) { newPolygon = new MapPolygon(); // Defines the polygon fill details newPolygon.Locations = new LocationCollection(); newPolygon.Fill = new SolidColorBrush(randColor.RandomColorOffSpeed(row.postcode)); newPolygon.Stroke = new SolidColorBrush(Colors.Green); newPolygon.StrokeThickness = 3; newPolygon.Opacity = 0.25; MapWithPolygon.Focus(); /// <summary> /// We used a script to get the longitude and latitude of 2 corners of a postalcode /// We then switched the x-axis and y-axis of these points so that we had 4 points in total /// These 4 points we then use to create squares on the map each representing a certain postalcode /// </summary> { // Add the four points to create a square that covers a postalcode newPolygon.Locations = new LocationCollection() { new Location((double)row.nelat, (double)row.swlng), new Location((double)row.nelat, (double)row.nelng), new Location((double)row.swlat, (double)row.nelng), new Location((double)row.swlat, (double)row.swlng) }; polygonPointLayer.Children.Clear(); // Add the points to the map NewPolygonLayer.Children.Add(newPolygon); } } } }