${iServerJava6R_ThemeUniqueItem_Title}

${iServerJava6R_ThemeUniqueItem_Description}

コード例 #1
0
        internal static ThemeUniqueItem FromJson(System.Json.JsonValue jsonValue)
        {
            if (jsonValue == null) { return null; };
            ThemeUniqueItem item = new ThemeUniqueItem();

            item.Caption = jsonValue["caption"];
            item.Style = ServerStyle.FromJson((JsonObject)jsonValue["style"]);
            item.Unique = jsonValue["unique"];
            item.Visible = (bool)jsonValue["visible"];
            return item;
        }
コード例 #2
0
        internal static string ToJson(ThemeUniqueItem item)
        {
            string json = "{";

            List<string> list = new List<string>();
            if (!string.IsNullOrEmpty(item.Caption))
            {
                list.Add(string.Format("\"caption\":\"{0}\"", item.Caption));
            }
            else
            {
                list.Add("\"caption\":\"\"");
            }

            //默认值这边儿是个问题,又不要判断呢?
            list.Add(string.Format("\"visible\":{0}", item.Visible.ToString(System.Globalization.CultureInfo.InvariantCulture).ToLower()));

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

            if (!string.IsNullOrEmpty(item.Unique))
            {
                list.Add(string.Format("\"unique\":\"{0}\"", item.Unique));
            }
            else
            {
                list.Add("\"unique\":\"\"");
            }

            json += string.Join(",", list.ToArray());
            json += "}";
            return json;
        }
        void service_ProcessCompleted(object sender, GenerateSpatialDataArgs e)
        {
            ThemeUniqueItem item1 = new ThemeUniqueItem();
            ServerStyle style1 = new ServerStyle();
            style1.FillForeColor = Color.FromArgb(255, 242, 48, 48);
            style1.LineColor = Color.FromArgb(255, 242, 48, 48);
            item1.Unique = "拥堵";
            item1.Style = style1;

            ThemeUniqueItem item2 = new ThemeUniqueItem();
            ServerStyle style2 = new ServerStyle();
            style2.FillForeColor = Color.FromArgb(255, 255, 159, 25);
            style2.LineColor = Color.FromArgb(255, 255, 159, 25);
            item2.Unique = "缓行";
            item2.Style = style2;

            ThemeUniqueItem item3 = new ThemeUniqueItem();
            ServerStyle style3 = new ServerStyle();
            style3.FillForeColor = Color.FromArgb(255, 91, 195, 69);
            style3.LineColor = Color.FromArgb(255, 91, 195, 69);
            item3.Unique = "畅通";
            item3.Style = style3;

            ThemeUnique themeUnique = new ThemeUnique();
            themeUnique.UniqueExpression = "TrafficStatus";
            themeUnique.Items = new List<ThemeUniqueItem>() { item1,item2,item3};

            ThemeParameters param = new ThemeParameters();
            param.DatasetName = "generateSpatialData";
            param.DataSourceName = "Changchun";
            param.Themes=new List<Theme>(){themeUnique};

            ThemeService themeService = new ThemeService(_mapUrl);
            themeService.ProcessCompleted += new EventHandler<ThemeEventArgs>(themeService_ProcessCompleted);
            themeService.ProcessAsync(param);
        }