${REST_ThemeDotDensity_Title}

${REST_ThemeDotDensity_Description}

상속: Theme
        //点击生成专题图触发事件
        private async void commit_Click(object sender, RoutedEventArgs e)
        {
            ThemeDotDensity themeDotDensity = new ThemeDotDensity
            {
                //专题图中每一个点所代表的数值
                Value = 10000000,
                //1994年人口字段
                DotExpression = "Pop_1994",
                Style = new ServerStyle
                {
                    //设置点符号
                    MarkerSize = 2,
                    MarkerSymbolID = 1,
                    FillForeColor = Color.FromArgb(255, 0, 180, 150),

                }
            };
            //专题图参数设置
            ThemeParameters dotDensityParams = new ThemeParameters
            {
                //数据集名称
                DatasetName = "Countries",
                //数据源名称
                DataSourceName = "World",
                Themes = new List<Theme> 
                {
                    themeDotDensity
                }
            };
            //与服务器交互成功
            try
            {
                ThemeService dotDensityService = new ThemeService(url);
                var result = await dotDensityService.ProcessAsync(dotDensityParams);
                //显示专题图。专题图在服务端为一个资源,每个资源都有一个 ID 号和一个 url
                //要显示专题图即将资源结果的 ID 号赋值给图层的 layersID 属性即可
                themeLayer.LayersID = result.ResourceInfo.NewResourceID;

                if (!this.MyMap.Layers.Contains(themeLayer))
                {
                    //加载专题图图层
                    this.MyMap.Layers.Add(themeLayer);
                }
                if (!themeLayer.IsVisible)
                {
                    themeLayer.IsVisible = true;
                }
            }
            //与服务器交互失败
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        internal static string ToJson(ThemeDotDensity dotDensity)
        {
            string json = "{";
            List<string> list = new List<string>();

            if (!string.IsNullOrEmpty(dotDensity.DotExpression))
            {
                list.Add(string.Format("\"dotExpression\":\"{0}\"", dotDensity.DotExpression));
            }
            else
            {
                list.Add("\"dotExpression\":\"\"");
            }

            if (dotDensity.Style != null)
            {
                list.Add(string.Format("\"style\":{0}", ServerStyle.ToJson(dotDensity.Style)));
            }
            else
            {
                list.Add(string.Format("\"style\":{0}", ServerStyle.ToJson(new ServerStyle())));
            }

            list.Add(string.Format("\"value\":{0}", dotDensity.Value.ToString()));

            list.Add("\"type\":\"DOTDENSITY\"");

            if (dotDensity.MemoryData!=null)
            {
                list.Add( "\"memoryData\":" + dotDensity.ToJson(dotDensity.MemoryData));
            }
            else
            {
                list.Add("\"memoryData\":null");
            }

            json += string.Join(",", list.ToArray());

            json += "}";
            return json;
        }
예제 #3
0
 internal static ThemeDotDensity FromJson(JsonObject json)
 {
     if (json == null) return null;
     ThemeDotDensity dotDensity = new ThemeDotDensity();
     dotDensity.DotExpression = json["dotExpression"].GetStringEx();
     dotDensity.Style = ServerStyle.FromJson(json["style"].GetObjectEx());
     dotDensity.Value = json["value"].GetNumberEx();
     return dotDensity;
 }
        private async void commit_Click(object sender, RoutedEventArgs e)
        {
            //专题图子项数组
            List<ThemeUniqueItem> items = new List<ThemeUniqueItem> 
            {
                //专题图子项
                 new ThemeUniqueItem
                 {
                     //SmID字段值
                     Unique="1", 
                     Style=new ServerStyle
                     {
                         FillForeColor = new Color {R=1,G=128,B=171},
                         LineWidth = 0.1                       
                     },
                     Visible=true,
                 },
                 new ThemeUniqueItem
                 {
                     //SmID字段值
                     Unique="247",
                     Style=new ServerStyle
                     {
                         FillForeColor= new Color {R=192,G=214,B=54},
                         LineWidth = 0.1
                     },
                     Visible=true,
                 }
            };
            //设置其他 SmID 字段显示风格
            ThemeUnique themeUnique = new ThemeUnique
            {
                Items = items,
                UniqueExpression = "SmID",
                DefaultStyle = new ServerStyle
                {
                    FillOpaqueRate = 100,
                    FillForeColor = new Color { R = 250, G = 237, B = 195 },
                    LineWidth = 0.1,
                    FillBackOpaque = true,
                    FillBackColor = Colors.Transparent
                }
            };

            ThemeDotDensity themeDotDensity = new ThemeDotDensity
            {
                //专题图中每一个点所代表的数值
                Value = 10000000,
                //1994年人口字段
                DotExpression = "Pop_1994",
                Style = new ServerStyle
                {
                    //设置点符号
                    MarkerSize = 2,
                    MarkerSymbolID = 1,
                    FillForeColor = Color.FromArgb(255, 0, 180, 150),
                }
            };
            //专题图参数设置
            ThemeParameters compostionThemeParameters = new ThemeParameters
            {
                DatasetName = "Countries",
                DataSourceName = "World",
                Themes = new List<Theme> { themeDotDensity, themeUnique }
            };
            // //与服务器交互成功
            try
            {
                ThemeService compositeService = new ThemeService(url);
                var result =  await compositeService.ProcessAsync(compostionThemeParameters);
                //显示专题图。专题图在服务端为一个资源,每个资源都有一个 ID 号和一个 url
                //要显示专题图即将资源结果的 ID 号赋值给图层的 layersID 属性即可
               
                themeLayer.LayersID = result.ResourceInfo.NewResourceID;
                if (!this.MyMap.Layers.Contains(themeLayer))
                {
                    //加载专题图图层
                    this.MyMap.Layers.Add(themeLayer);
                }
                if (!themeLayer.IsVisible)
                {
                    themeLayer.IsVisible = true;
                }
            }
            //与服务器交互失败
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            } 
        }