大佬教程收集整理的这篇文章主要介绍了ArcGIS API for Silverlight 地图中解决点众多的簇解决方法,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
1、通用类
#region 多点的簇显示 public class SumClusterer : GraphicsClusterer { public SumClusterer() { MinimumColor = Colors.Red; MaximumColor = Colors.Yellow; SymbolScale = 2; base.Radius = 100; } public @R_673_10495@ng Aggregatecolumn { get; set; } public double SymbolScale { get; set; } public Color MinimumColor { get; set; } public Color MaximumColor { get; set; } protected override Graphic OnCreateGraphic(GraphicCollection cluster,MapPoint point,int maxClusterCount) { if (cluster.Count == 1) return cluster[0]; Graphic graphic = null; double sum = 0; foreach (Graphic g in cluster) { if (g.Attributes.ContainsKey(Aggregatecolumn)) { try { sum += Convert.ToDouble(g.Attributes[Aggregatecolumn]); } catch { } } } double size = (sum + 450) / 30; size = (Math.Log(sum * SymbolScale / 10) * 10 + 20); if (size < 12) size = 12; graphic = new Graphic() { Symbol = new clustersymbol() { Size = size },Geometry = point }; graphic.Attributes.Add("Count",sum); graphic.Attributes.Add("Size",sizE); graphic.Attributes.Add("Color",InterpolateColor(size - 12,100)); return graphic; } private static Brush InterpolateColor(double value,double maX) { value = (int)R_96_11845@ath.round(value * 255.0 / maX); if (value > 255) value = 255; else if (value < 0) value = 0; return new SolidColorBrush(Color.FromArgb(127,255,(bytE)value,0)); } } internal class clustersymbol : ESRI.ArcGIs.CLIENt.Symbols.MarkerSymbol { public clustersymbol() { @R_673_10495@ng template = @" <ControlTemplate xmlns=""http://scheR_96_11845@as.microsoft.com/client/2007"" xmlns:x=""http://scheR_96_11845@as.microsoft.com/winfx/2006/xaml"" > <Grid IsHitTestVisible=""false""> <Ellipse Fill=""{Binding Attributes[Color]}"" Width=""{Binding Attributes[Size]}"" Height=""{Binding Attributes[Size]}"" /> <Grid HorizontalAlignment=""Center"" VerticalAlignment=""Center""> <TextBlock Text=""{Binding Attributes[Count]}"" FontSize=""9"" Margin=""1,1,0"" FontWeight=""Bold"" Foreground=""#99000000"" /> <TextBlock Text=""{Binding Attributes[Count]}"" FontSize=""9"" Margin=""0,1"" FontWeight=""Bold"" Foreground=""White"" /> </Grid> </Grid> </ControlTemplate>"; this.ControlTemplate = System.Windows.Markup.XamlReader.Load(templatE) as ControlTemplate; } public double Size { get; set; } public override double OffsetX { get { return Size / 2; } set { throw new NotSupportedException(); } } public override double OffsetY { get { return Size / 2; } set { throw new NotSupportedException(); } } } #endregion
void client_GetMonitorInfoCompleted(object sender,GetMonitorInfoCompletedEventArgs E) { ObservableCollection<MonitorInfo> list = e.Result; ESRI.ArcGIs.CLIENt.Projection.WebMercator mercator = new ESRI.ArcGIs.CLIENt.Projection.WebMercator(); GraphicsLayer graphicsLayer = mymap.Layers["MyGraphicsLayer"] as GraphicsLayer; //每次加载时先清空地图上数据 graphicsLayer.ClearGraphics(); Uri uri = null; Graphic graphic = null; foreach (MonitorInfo item in list) { if (!@R_673_10495@ng.IsNullOrEmpty(item.Latitute.To@R_673_10495@ng()) && !@R_673_10495@ng.IsNullOrEmpty(item.Longitute.To@R_673_10495@ng())) { //有坐标值时,将该监测点添加到地图上去 graphic = new Graphic() { Geometry = mercator.FromGeographic(new MapPoint(double.Parse(item.Latitute.To@R_673_10495@ng().Trim()),double.Parse(item.Longitute.To@R_673_10495@ng().Trim()))),Symbol = LayoutRoot.resources["DefaultMarkerSymbol"] as Symbol,}; //手动为graphic添加属性(需要用到的和数据库表之间的关联) graphic.Attributes["Id"] = item.ID; graphic.Attributes["Name"] = item.Name; graphic.Attributes["AreaID"] = item.countyAreaID; for (int i = 0; i < areaId.Length; i++) { if (areaId[i] == item.ID.To@R_673_10495@ng()) { switch (seedlingType[i]) { case "1": uri = new Uri("Images/red.png",UriKind.RelativE); break; case "2": uri = new Uri("Images/yellow.png",UriKind.RelativE); break; case "3": uri = new Uri("Images/green.png",UriKind.RelativE); break; case "4": uri = new Uri("Images/red.png",UriKind.RelativE); break; default: break; } } } BitmapImage image = new BitmapImage(uri); //定义Symbol样式,包括填充颜色 Symbol symbol = new PictuREMARKerSymbol() { OffsetX = 8,OffsetY = 8,source = image }; graphic.Symbol = symbol; //将该Graphics添加到GraphicsLayer中去 graphicsLayer.Graphics.Add(graphic); //为众多的监测点提供簇聚合功能 graphicsLayer.Clusterer = new SumClusterer() { Aggregatecolumn = "AreaID",SymbolScale = 0.008 }; //左键@L_262_10@ graphic.MouSELEftButtonDown += new MouseButtonEventHandler(Feature_MouSELEftButtonDown); graphic.MouSELEftButtonUp += new MouseButtonEventHandler(Feature_MouSELEftButtonUp); //右键@L_262_10@ graphic.MouseRightButtonDown += new MouseButtonEventHandler(Feature_MouseRightButtonDown); graphic.MouseRightButtonUp += new MouseButtonEventHandler(Feature_MouseRightButtonUp); } else { //不做任何处理,不添加任何点信息 } //坐标点聚焦 ESRI.ArcGIs.CLIENt.Geometry.Envelope SELEctedFeatureExtent = graphic.Geometry.Extent; //最后一个点的位置 double expandPercentage = 30; double widthExpand = SELEctedFeatureExtent.Width * (expandPercentage / 100); double heightExpand = SELEctedFeatureExtent.Height * (expandPercentage / 100); ESRI.ArcGIs.CLIENt.Geometry.Envelope displayExtent = new ESRI.ArcGIs.CLIENt.Geometry.Envelope( SELEctedFeatureExtent.XMin - (widthExpand / 2),SELEctedFeatureExtent.ymin - (heightExpand / 2),SELEctedFeatureExtent.XMax + (widthExpand / 2),SELEctedFeatureExtent.ymax + (heightExpand / 2)); mymap.ZoomTo(displayExtent); } }
以上是大佬教程为你收集整理的ArcGIS API for Silverlight 地图中解决点众多的簇解决方法全部内容,希望文章能够帮你解决ArcGIS API for Silverlight 地图中解决点众多的簇解决方法所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。