public void RenderMarker(int size, Brush markerColor, SimpleMarkerSymbol.SimpleMarkerStyle style) { this.size = size; this.markerColor = markerColor; this.style = style; GraphicsLayer markerLayer = myMap.Layers[layerId.ToString()] as GraphicsLayer; if (markerLayer != null) { markerLayer.Graphics.Clear(); } else { markerLayer = new GraphicsLayer(); markerLayer.ID = layerId.ToString(); myMap.Layers.Add(markerLayer); } markerLayer.Graphics.Add(new Graphic() { Geometry = point, Symbol = MarkerSymbol }); }
public void RenderPointMap(DashboardHelper dashboardHelper, string latVar, string longVar, Brush pointColor, string timeVar, SimpleMarkerSymbol.SimpleMarkerStyle style, string description) { this.dashboardHelper = dashboardHelper; this.latVar = latVar; this.longVar = longVar; this.timeVar = timeVar; this.style = style; this.description = description; this.pointColor = (SolidColorBrush)pointColor; GraphicsLayer pointLayer = myMap.Layers[layerId.ToString()] as GraphicsLayer; if (pointLayer != null) { pointLayer.Graphics.Clear(); } else { pointLayer = new GraphicsLayer(); pointLayer.ID = layerId.ToString(); myMap.Layers.Add(pointLayer); } CustomCoordinateList coordinateList = GetCoordinates(dashboardHelper, latVar, longVar, timeVar); for (int i = 0; i < coordinateList.Coordinates.Count; i++) { ExtendedGraphic graphic = new ExtendedGraphic() { Geometry = new MapPoint(coordinateList.Coordinates[i].X, coordinateList.Coordinates[i].Y, geoReference), RecordId = coordinateList.Coordinates[i].RecordId, Symbol = MarkerSymbol }; if (coordinateList.Coordinates[i].TimeSpan.HasValue) { graphic.TimeExtent = new TimeExtent(coordinateList.Coordinates[i].TimeSpan.Value); } else { graphic.TimeExtent = new TimeExtent(DateTime.MinValue, DateTime.MaxValue); } graphic.MouseLeftButtonUp += new MouseButtonEventHandler(graphic_MouseLeftButtonUp); pointLayer.Graphics.Add(graphic); } if (LegendStackPanel == null) { LegendStackPanel = new StackPanel(); } LegendStackPanel.Children.Clear(); if (string.IsNullOrEmpty(description)) { description = SharedStrings.CASES; } if (!string.IsNullOrEmpty(description)) { System.Windows.Controls.ListBox legendList = new System.Windows.Controls.ListBox(); legendList.Padding = new Thickness(0, 10, 0, 0); legendList.Background = Brushes.White; legendList.BorderBrush = Brushes.Black; legendList.BorderThickness = new Thickness(0); legendList.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); TextBlock classTextBlock = new TextBlock(); classTextBlock.Text = description; classTextBlock.FontFamily = new FontFamily("Segoe"); classTextBlock.FontSize = 12; classTextBlock.MaxWidth = 256; classTextBlock.TextWrapping = TextWrapping.Wrap; classTextBlock.HorizontalAlignment = HorizontalAlignment.Center; classTextBlock.VerticalAlignment = VerticalAlignment.Center; classTextBlock.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); TextBlock symbolTextBlock = new TextBlock(); switch (style) { case SimpleMarkerSymbol.SimpleMarkerStyle.Circle: symbolTextBlock.Text = "●"; symbolTextBlock.FontSize = 16; break; case SimpleMarkerSymbol.SimpleMarkerStyle.Cross: symbolTextBlock.Text = "+"; symbolTextBlock.FontSize = 18; symbolTextBlock.FontWeight = FontWeights.Bold; break; case SimpleMarkerSymbol.SimpleMarkerStyle.Diamond: symbolTextBlock.Text = "♦"; symbolTextBlock.FontSize = 17; break; case SimpleMarkerSymbol.SimpleMarkerStyle.Square: symbolTextBlock.Text = "■"; symbolTextBlock.FontSize = 16; break; case SimpleMarkerSymbol.SimpleMarkerStyle.Triangle: symbolTextBlock.Text = "▲"; symbolTextBlock.FontSize = 16; break; default: symbolTextBlock.Text = "▲"; symbolTextBlock.FontSize = 16; break; } symbolTextBlock.FontSize = 28; symbolTextBlock.VerticalAlignment = VerticalAlignment.Top; symbolTextBlock.Margin = new Thickness(0, 4, 7, 4); symbolTextBlock.Foreground = this.pointColor; StackPanel classStackPanel = new StackPanel(); classStackPanel.Margin = new Thickness(10, 0, 10, 10); classStackPanel.Orientation = System.Windows.Controls.Orientation.Horizontal; classStackPanel.Children.Add(symbolTextBlock); classStackPanel.Children.Add(classTextBlock); legendList.Items.Add(classStackPanel); LegendStackPanel.Children.Add(legendList); } if (coordinateList.Coordinates.Count > 0) { myMap.Extent = new Envelope(ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(minX - 0.01, minY - 0.01, geoReference)), ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(maxX + 0.01, maxY + 0.01, geoReference))); if (!string.IsNullOrEmpty(timeVar)) { if (minTime != null && maxTime != null) { intervalCounts = new List <KeyValuePair <DateTime, int> >(); DateTime previousInterval = DateTime.MinValue; IEnumerable <DateTime> intervals = TimeSlider.CreateTimeStopsByTimeInterval(new TimeExtent(minTime, maxTime), new TimeSpan(1, 0, 0, 0)); foreach (DateTime interval in intervals) { int count = pointLayer.Graphics.Count(x => x.TimeExtent.Start <= interval && x.TimeExtent.Start >= previousInterval); intervalCounts.Add(new KeyValuePair <DateTime, int>(interval.Date, count)); previousInterval = interval; } if (DateRangeDefined != null) { DateRangeDefined(minTime, maxTime, intervalCounts); } } } } }
public void RenderPointMap(DashboardHelper dashboardHelper, string latVar, string longVar, Brush pointColor, string timeVar, SimpleMarkerSymbol.SimpleMarkerStyle style, string description) { this.dashboardHelper = dashboardHelper; this.latVar = latVar; this.longVar = longVar; this.timeVar = timeVar; this.style = style; this.description = description; this.pointColor = (SolidColorBrush)pointColor; GraphicsLayer pointLayer = myMap.Layers[layerId.ToString()] as GraphicsLayer; if (pointLayer != null) { pointLayer.Graphics.Clear(); } else { pointLayer = new GraphicsLayer(); pointLayer.ID = layerId.ToString(); myMap.Layers.Add(pointLayer); } CustomCoordinateList coordinateList = GetCoordinates(dashboardHelper, latVar, longVar, timeVar); for (int i = 0; i < coordinateList.Coordinates.Count; i++) { ExtendedGraphic graphic = new ExtendedGraphic() { Geometry = new MapPoint(coordinateList.Coordinates[i].X, coordinateList.Coordinates[i].Y, geoReference), RecordId = coordinateList.Coordinates[i].RecordId, Symbol = MarkerSymbol }; if (coordinateList.Coordinates[i].TimeSpan.HasValue) graphic.TimeExtent = new TimeExtent(coordinateList.Coordinates[i].TimeSpan.Value); else graphic.TimeExtent = new TimeExtent(DateTime.MinValue, DateTime.MaxValue); graphic.MouseLeftButtonUp += new MouseButtonEventHandler(graphic_MouseLeftButtonUp); pointLayer.Graphics.Add(graphic); } if (LegendStackPanel == null) { LegendStackPanel = new StackPanel(); } LegendStackPanel.Children.Clear(); if (!string.IsNullOrEmpty(description)) { System.Windows.Controls.ListBox legendList = new System.Windows.Controls.ListBox(); legendList.Margin = new Thickness(5); legendList.Background = Brushes.White;// new LinearGradientBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), Color.FromArgb(0x7F, 0xFF, 0xFF, 0xFF), 45); legendList.BorderBrush = Brushes.Black; legendList.BorderThickness = new Thickness(3); //LegendTitle.Text = thematicItem.Description; TextBlock classTextBlock = new TextBlock(); classTextBlock.Text = " " + description; classTextBlock.FontSize = 15; TextBlock symbolTextBlock = new TextBlock(); switch (style) { case SimpleMarkerSymbol.SimpleMarkerStyle.Circle: symbolTextBlock.Text = "●"; symbolTextBlock.FontSize = 18; break; case SimpleMarkerSymbol.SimpleMarkerStyle.Cross: symbolTextBlock.Text = "+"; symbolTextBlock.FontSize = 18; symbolTextBlock.FontWeight = FontWeights.Bold; break; case SimpleMarkerSymbol.SimpleMarkerStyle.Diamond: symbolTextBlock.Text = "♦"; symbolTextBlock.FontSize = 17; break; case SimpleMarkerSymbol.SimpleMarkerStyle.Square: symbolTextBlock.Text = "■"; symbolTextBlock.FontSize = 16; break; case SimpleMarkerSymbol.SimpleMarkerStyle.Triangle: symbolTextBlock.Text = "▲"; symbolTextBlock.FontSize = 16; break; default: symbolTextBlock.Text = "▲"; symbolTextBlock.FontSize = 16; break; } symbolTextBlock.Foreground = this.pointColor; StackPanel classStackPanel = new StackPanel(); classStackPanel.Orientation = System.Windows.Controls.Orientation.Horizontal; classStackPanel.Children.Add(symbolTextBlock); classStackPanel.Children.Add(classTextBlock); legendList.Items.Add(classStackPanel); LegendStackPanel.Children.Add(legendList); } if (coordinateList.Coordinates.Count > 0) { myMap.Extent = new Envelope(ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(minX - 0.01, minY - 0.01, geoReference)), ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(maxX + 0.01, maxY + 0.01, geoReference))); if (!string.IsNullOrEmpty(timeVar)) { if (minTime != null && maxTime != null) { intervalCounts = new List<KeyValuePair<DateTime, int>>(); DateTime previousInterval = DateTime.MinValue; IEnumerable<DateTime> intervals = TimeSlider.CreateTimeStopsByTimeInterval(new TimeExtent(minTime, maxTime), new TimeSpan(1, 0, 0, 0)); foreach (DateTime interval in intervals) { int count = pointLayer.Graphics.Count(x => x.TimeExtent.Start <= interval && x.TimeExtent.Start >= previousInterval); intervalCounts.Add(new KeyValuePair<DateTime, int>(interval.Date, count)); previousInterval = interval; } if (DateRangeDefined != null) { DateRangeDefined(minTime, maxTime, intervalCounts); } } } } }