Hi,
I am using MsSql2008FeatureLayer and I do apply different style per level of zoom and I am finding some weird behavior…
the style I expect on a zoom level popup on another zoom level and not the one I want…
wondering if the logic has not been reversed somewhere?
privatestaticvoidApplyStyles(MsSql2008FeatureLayer sql2008FeatureLayer) {sql2008FeatureLayer.ZoomLevelSet.CustomZoomLevels.Clear();
#region Style templates
var publicLocationBrush =newGeoHatchBrush(GeoHatchStyle.Percent05, GeoColor.SimpleColors.Black) {ForegroundColor = GeoColor.FromArgb(86,GeoColor.StandardColors.Gray),BackgroundColor =newGeoColor(70, 98, 196, 98)};
var restrictedBrush =newGeoHatchBrush(GeoHatchStyle.Percent05, GeoColor.SimpleColors.Black) {ForegroundColor = GeoColor.FromArgb(86,GeoColor.StandardColors.Gray),BackgroundColor =newGeoColor(70, 255, 0, 0)};
var manufacturingLocation =newValueItem {DefaultPointStyle =newPointStyle {Name = Guid.NewGuid().ToString(),PointType = PointType.Symbol,SymbolType = PointSymbolType.Circle,SymbolPen =newGeoPen(GeoColor.StandardColors.Black, 1),SymbolSize = 6,SymbolSolidBrush =newGeoSolidBrush(newGeoColor(255, 98, 196, 98)),XOffsetInPixel = -5},DefaultLineStyle =newLineStyle {Name = Guid.NewGuid().ToString(),CenterPen =newGeoPen(newGeoColor(255, 255, 255, 255))},DefaultAreaStyle =newAreaStyle {Name = Guid.NewGuid().ToString(),OutlinePen =newGeoPen(GeoColor.SimpleColors.Black),Advanced = {FillCustomBrush = publicLocationBrush}},DefaultTextStyle =null,Value ="1"};
var stdLocation =newValueItem {DefaultPointStyle =newPointStyle {Name = Guid.NewGuid().ToString(),PointType = PointType.Symbol,SymbolType = PointSymbolType.Circle,SymbolPen =newGeoPen(GeoColor.StandardColors.Black, 1),SymbolSize = 6,SymbolSolidBrush =newGeoSolidBrush(newGeoColor(255, 255, 0, 0)),XOffsetInPixel = -5},DefaultLineStyle =newLineStyle {Name = Guid.NewGuid().ToString(),CenterPen =newGeoPen(newGeoColor(255, 255, 255, 255))},DefaultAreaStyle =newAreaStyle {Name = Guid.NewGuid().ToString(),OutlinePen =newGeoPen(GeoColor.SimpleColors.Black),Advanced = {FillCustomBrush = restrictedBrush}},DefaultTextStyle =null,Value ="0"};
#endregion
ValueStyle vstyle;
Debug.Assert(sql2008FeatureLayer !=null,"sql2008FeatureLayer != null");sql2008FeatureLayer.Open();sql2008FeatureLayer.FeatureSource.Open();IOrderedEnumerable<string> keyAccountBusinessName =sql2008FeatureLayer.FeatureSource.GetAllFeatures(new[] {"KeyAccountBusinessName"}).Where(e => e.ColumnValues["KeyAccountBusinessName"] !="").Select(e => e.ColumnValues["KeyAccountBusinessName"].ToString(CultureInfo.InvariantCulture)).Distinct().OrderBy(e => e);sql2008FeatureLayer.FeatureSource.Close();sql2008FeatureLayer.Close();
var valueStyleBus =newValueStyle {ColumnName ="KeyAccountBusinessName"};
Collection<GeoColor> colorsInQualityFamily =GeoColor.GetColorsInQualityFamily(GeoColor.FromArgb(90, GeoColor.SimpleColors.Blue),keyAccountBusinessName.Count());
vstyle =newValueStyle {ColumnName ="LocationStyleValue", Name = Guid.NewGuid().ToString()};vstyle.ValueItems.Clear();
vstyle.ValueItems.Add(manufacturingLocation);vstyle.ValueItems.Add(stdLocation);sql2008FeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();sql2008FeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(vstyle);sql2008FeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level16;
vstyle =newValueStyle {ColumnName ="LocationStyleValue", Name = Guid.NewGuid().ToString()};vstyle.ValueItems.Clear();
manufacturingLocation.DefaultTextStyle =newTextStyle {Name = Guid.NewGuid().ToString(),TextColumnName ="KeyAccountBusinessName",TextSolidBrush =newGeoSolidBrush(GeoColor.SimpleColors.Black),BestPlacement =true,Font =newGeoFont("Arial", 12),SuppressPartialLabels =true,DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels};
stdLocation.DefaultTextStyle =newTextStyle {Name = Guid.NewGuid().ToString(),TextColumnName ="KeyAccountBusinessName",TextSolidBrush =newGeoSolidBrush(GeoColor.SimpleColors.Black),BestPlacement =true,Font =newGeoFont("Arial", 12),SuppressPartialLabels =true,DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels};
vstyle.ValueItems.Add(manufacturingLocation);vstyle.ValueItems.Add(stdLocation);
sql2008FeatureLayer.ZoomLevelSet.ZoomLevel17.CustomStyles.Add(vstyle);sql2008FeatureLayer.ZoomLevelSet.ZoomLevel17.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level17;
vstyle =newValueStyle {ColumnName ="LocationStyleValue", Name = Guid.NewGuid().ToString()};vstyle.ValueItems.Clear();
manufacturingLocation.DefaultTextStyle =newTextStyle {Name = Guid.NewGuid().ToString(),TextColumnName ="KeyAccountBusinessName",TextSolidBrush =newGeoSolidBrush(GeoColor.SimpleColors.Black),BestPlacement =true,Font =newGeoFont("Arial", 13),SuppressPartialLabels =true,DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels};stdLocation.DefaultTextStyle =newTextStyle {Name = Guid.NewGuid().ToString(),TextColumnName ="KeyAccountBusinessName",TextSolidBrush =newGeoSolidBrush(GeoColor.SimpleColors.Black),BestPlacement =true,Font =newGeoFont("Arial", 13),SuppressPartialLabels =true,DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels};
vstyle.ValueItems.Add(manufacturingLocation);vstyle.ValueItems.Add(stdLocation);
sql2008FeatureLayer.ZoomLevelSet.ZoomLevel18.CustomStyles.Add(vstyle);sql2008FeatureLayer.ZoomLevelSet.ZoomLevel18.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level18;
vstyle =newValueStyle {ColumnName ="LocationStyleValue", Name = Guid.NewGuid().ToString()};vstyle.ValueItems.Clear();
manufacturingLocation.DefaultTextStyle =newTextStyle {Name = Guid.NewGuid().ToString(),TextColumnName ="KeyAccountBusinessName",TextSolidBrush =newGeoSolidBrush(GeoColor.SimpleColors.Black),BestPlacement =true,Font =newGeoFont("Arial", 16),SuppressPartialLabels =true,DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels};stdLocation.DefaultTextStyle =newTextStyle {Name = Guid.NewGuid().ToString(),TextColumnName ="KeyAccountBusinessName",TextSolidBrush =newGeoSolidBrush(GeoColor.SimpleColors.Black),BestPlacement =true,Font =newGeoFont("Arial", 16),SuppressPartialLabels =true,DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels};
vstyle.ValueItems.Add(manufacturingLocation);vstyle.ValueItems.Add(stdLocation);
sql2008FeatureLayer.ZoomLevelSet.ZoomLevel19.CustomStyles.Add(vstyle);sql2008FeatureLayer.ZoomLevelSet.ZoomLevel19.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level19;
sql2008FeatureLayer.DrawingQuality = DrawingQuality.HighQuality;}
jm.