static StyleSelector createPlacemarkLineStyleMap(Style normalStyle, Style highlightStyle) { // Set up style map StyleMapCollection styleMapCollection = new StyleMapCollection(); styleMapCollection.Id = String.Format("stylemap"); // Create the normal line pair Pair normalPair = new Pair(); normalPair.StyleUrl = new Uri(String.Format("#{0}", normalStyle.Id), UriKind.Relative); normalPair.State = StyleState.Normal; // Create the highlight line pair Pair highlightPair = new Pair(); highlightPair.StyleUrl = new Uri(String.Format("#{0}", highlightStyle.Id), UriKind.Relative); highlightPair.State = StyleState.Highlight; // Attach both pairs to the map styleMapCollection.Add(normalPair); styleMapCollection.Add(highlightPair); return(styleMapCollection); }
private StyleSelector CreateStyleMap(Uri url) { // This is the same order as the C++ version - Normal then Highlight var map = new StyleMapCollection(); map.Add(this.CreatePair(StyleState.Normal, url)); map.Add(this.CreatePair(StyleState.Highlight, url)); return map; }
public static void AddStylesForPolygon(Document document, string[] styleNames) { // adding a stylemap that can be referenced from the elements Color32[] polyColors = { new Color32(80, 0, 0, 255), new Color32(255, 255, 255, 255) }; Color32[] lineColors = { new Color32(255, 0, 0, 255), new Color32(255, 255, 255, 255) }; bool[] polyFills = { true, false }; bool[] polyOutlines = { true, true }; // create two styles, both contain definitions for LineStyle and PolygonStyle for (int i = 0; i < styleNames.Length; i++) { StyleMapCollection smc = new StyleMapCollection(); Style[] stylePolyAndLine = { new Style(), new Style() }; PolygonStyle stPoly = new PolygonStyle(); stPoly.Color = polyColors[i]; stPoly.ColorMode = ColorMode.Normal; stPoly.Fill = polyFills[i]; stPoly.Outline = polyOutlines[i]; LineStyle stLine = new LineStyle(); stLine.Color = lineColors[i]; stLine.ColorMode = ColorMode.Normal; stylePolyAndLine[0].Id = styleNames[i] + "_Normal"; stylePolyAndLine[0].Polygon = stPoly; stylePolyAndLine[0].Line = stLine; document.AddStyle(stylePolyAndLine[0]); stylePolyAndLine[1].Id = styleNames[i] + "_High"; stylePolyAndLine[1].Polygon = stPoly; stylePolyAndLine[1].Line = stLine; document.AddStyle(stylePolyAndLine[1]); // create a StyleMap collection and add above Styles as a pair // with different Style States smc.Id = styleNames[i]; Pair[] pr = { new Pair(), new Pair() }; pr[0].State = StyleState.Normal; pr[0].StyleUrl = new Uri("#" + styleNames[i] + "_Normal", UriKind.Relative); smc.Add(pr[0]); pr[1].State = StyleState.Highlight; pr[1].StyleUrl = new Uri("#" + styleNames[i] + "_High", UriKind.Relative); smc.Add(pr[1]); // add the stylemap collection to the document (in the same way as a style) document.AddStyle(smc); } }
public StyleMap(Style style1, Style style2) { var pair1 = new Pair(); pair1.State = StyleState.Normal; pair1.StyleUrl = new Uri("#" + style1.Id, UriKind.Relative); var pair2 = new Pair(); pair2.State = StyleState.Highlight; pair2.StyleUrl = new Uri("#" + style2.Id, UriKind.Relative); //var styleMap = new StyleMapCollection(); _styleMap.Add(pair1); _styleMap.Add(pair2); _styleMap.Id = "Point_hide_show"; }
private StyleMapCollection GenerateNewStyle(string str, Feature feature, Location loc) { Color32 c = GetRandomColor(); StyleMapCollection stylemap = new StyleMapCollection(); StyleMapCollection stylemap2 = new StyleMapCollection(); Style s_normal = new Style() { Icon = new IconStyle { Icon = new IconStyle.IconLink(new Uri("http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png")), Color = c }, Id = $"sn_{str}", Label = new LabelStyle() { Scale = 0.5 }, Line = new LineStyle() { Color = new Color32(255 / 2, c.Blue, c.Green, c.Red) } }; Style s_nolabels = new Style() { Icon = new IconStyle { Icon = new IconStyle.IconLink(new Uri("http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png")), Color = c }, Id = $"sn_{str}_nolabels", Label = new LabelStyle() { Scale = 0.01 }, Line = new LineStyle() { Color = new Color32(255 / 2, c.Blue, c.Green, c.Red) } }; Style s_highlight = new Style() { Icon = new IconStyle { Icon = new IconStyle.IconLink(new Uri("http://maps.google.com/mapfiles/kml/shapes/placemark_circle_highlight.png")), Color = c }, Line = new LineStyle() { Color = new Color32(255, c.Blue, c.Green, c.Red), Width = 4 }, Id = $"sn_{str}_highlight", }; stylemap.Id = $"msn_{str}"; stylemap.Add(new Pair() { State = StyleState.Normal, StyleUrl = new Uri($"#{s_normal.Id}", UriKind.Relative) }); stylemap.Add(new Pair() { State = StyleState.Highlight, StyleUrl = new Uri($"#{s_highlight.Id}", UriKind.Relative) }); stylemap2.Id = $"msn_{str}_nolabels"; stylemap2.Add(new Pair() { State = StyleState.Normal, StyleUrl = new Uri($"#{s_nolabels.Id}", UriKind.Relative) }); stylemap2.Add(new Pair() { State = StyleState.Highlight, StyleUrl = new Uri($"#{s_highlight.Id}", UriKind.Relative) }); feature.AddStyle(stylemap); feature.AddStyle(stylemap2); feature.AddStyle(s_normal); feature.AddStyle(s_nolabels); feature.AddStyle(s_highlight); if (loc != null) { loc.StyleMap = stylemap; loc.StyleMapNoLabels = stylemap2; } return(Labels == LabelMode.All ? stylemap : stylemap2); }