ThinkGeo.com    |     Documentation    |     Premium Support

Maybe a bug!

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?


private static void ApplyStyles(MsSql2008FeatureLayer sql2008FeatureLayer) {
            sql2008FeatureLayer.ZoomLevelSet.CustomZoomLevels.Clear();
 
            #region Style templates
 
            var publicLocationBrush = new GeoHatchBrush(GeoHatchStyle.Percent05, GeoColor.SimpleColors.Black) {
                ForegroundColor = GeoColor.FromArgb(86,
                    GeoColor.StandardColors.Gray),
                BackgroundColor = new GeoColor(70, 98, 196, 98)
            };
 
            var restrictedBrush = new GeoHatchBrush(GeoHatchStyle.Percent05, GeoColor.SimpleColors.Black) {
                ForegroundColor = GeoColor.FromArgb(86,
                    GeoColor.StandardColors.Gray),
                BackgroundColor = new GeoColor(70, 255, 0, 0)
            };
 
            var manufacturingLocation = new ValueItem {
                DefaultPointStyle =
                    new PointStyle {
                        Name = Guid.NewGuid().ToString(),
                        PointType = PointType.Symbol,
                        SymbolType = PointSymbolType.Circle,
                        SymbolPen = new GeoPen(GeoColor.StandardColors.Black, 1),
                        SymbolSize = 6,
                        SymbolSolidBrush = new GeoSolidBrush(new GeoColor(255, 98, 196, 98)),
                        XOffsetInPixel = -5
                    },
                DefaultLineStyle =
                    new LineStyle {
                        Name = Guid.NewGuid().ToString(),
                        CenterPen = new GeoPen(new GeoColor(255, 255, 255, 255))
                    },
                DefaultAreaStyle =
                    new AreaStyle {
                        Name = Guid.NewGuid().ToString(),
                        OutlinePen = new GeoPen(GeoColor.SimpleColors.Black),
                        Advanced = {FillCustomBrush = publicLocationBrush}
                    },
                DefaultTextStyle = null,
                Value = "1"
            };
 
 
            var stdLocation = new ValueItem {
                DefaultPointStyle =
                    new PointStyle {
                        Name = Guid.NewGuid().ToString(),
                        PointType = PointType.Symbol,
                        SymbolType = PointSymbolType.Circle,
                        SymbolPen = new GeoPen(GeoColor.StandardColors.Black, 1),
                        SymbolSize = 6,
                        SymbolSolidBrush = new GeoSolidBrush(new GeoColor(255, 255, 0, 0)),
                        XOffsetInPixel = -5
                    },
                DefaultLineStyle =
                    new LineStyle {
                        Name = Guid.NewGuid().ToString(),
                        CenterPen = new GeoPen(new GeoColor(255, 255, 255, 255))
                    },
                DefaultAreaStyle =
                    new AreaStyle {
                        Name = Guid.NewGuid().ToString(),
                        OutlinePen = new GeoPen(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 = new ValueStyle {ColumnName = "KeyAccountBusinessName"};
 
            Collection<GeoColor> colorsInQualityFamily =
                GeoColor.GetColorsInQualityFamily(GeoColor.FromArgb(90, GeoColor.SimpleColors.Blue),
                    keyAccountBusinessName.Count());
 
 
            vstyle = new ValueStyle {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 = new ValueStyle {ColumnName = "LocationStyleValue", Name = Guid.NewGuid().ToString()};
            vstyle.ValueItems.Clear();
 
            manufacturingLocation.DefaultTextStyle = new TextStyle {
                Name = Guid.NewGuid().ToString(),
                TextColumnName = "KeyAccountBusinessName",
                TextSolidBrush = new GeoSolidBrush(GeoColor.SimpleColors.Black),
                BestPlacement = true,
                Font = new GeoFont("Arial", 12),
                SuppressPartialLabels = true,
                DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels
            };
 
            stdLocation.DefaultTextStyle = new TextStyle {
                Name = Guid.NewGuid().ToString(),
                TextColumnName = "KeyAccountBusinessName",
                TextSolidBrush = new GeoSolidBrush(GeoColor.SimpleColors.Black),
                BestPlacement = true,
                Font = new GeoFont("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 = new ValueStyle {ColumnName = "LocationStyleValue", Name = Guid.NewGuid().ToString()};
            vstyle.ValueItems.Clear();
 
            manufacturingLocation.DefaultTextStyle = new TextStyle {
                Name = Guid.NewGuid().ToString(),
                TextColumnName = "KeyAccountBusinessName",
                TextSolidBrush = new GeoSolidBrush(GeoColor.SimpleColors.Black),
                BestPlacement = true,
                Font = new GeoFont("Arial", 13),
                SuppressPartialLabels = true,
                DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels
            };
            stdLocation.DefaultTextStyle = new TextStyle {
                Name = Guid.NewGuid().ToString(),
                TextColumnName = "KeyAccountBusinessName",
                TextSolidBrush = new GeoSolidBrush(GeoColor.SimpleColors.Black),
                BestPlacement = true,
                Font = new GeoFont("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 = new ValueStyle {ColumnName = "LocationStyleValue", Name = Guid.NewGuid().ToString()};
            vstyle.ValueItems.Clear();
 
            manufacturingLocation.DefaultTextStyle = new TextStyle {
                Name = Guid.NewGuid().ToString(),
                TextColumnName = "KeyAccountBusinessName",
                TextSolidBrush = new GeoSolidBrush(GeoColor.SimpleColors.Black),
                BestPlacement = true,
                Font = new GeoFont("Arial", 16),
                SuppressPartialLabels = true,
                DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels
            };
            stdLocation.DefaultTextStyle = new TextStyle {
                Name = Guid.NewGuid().ToString(),
                TextColumnName = "KeyAccountBusinessName",
                TextSolidBrush = new GeoSolidBrush(GeoColor.SimpleColors.Black),
                BestPlacement = true,
                Font = new GeoFont("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.

I have done more test and I think that something is wrong with zoomlevel and customstyles… 
  
 jm

Hi Jm, 
  
 I noticed you are referring to the same declare "vstyle" on the different zoomlevels which means the other zoomlevels you set before will be covered by the zoomlevel19. Would you please check if it is the root of the issue? 
  
 If the issue persists, we are expected a concrete sample to recreate the issue. 
 Thanks, 
 Troy 


Hi, 
  
 You mean that I cannot  use the same object declaration again and again even if I do create a new instance per level of zoom? 
  
 JM.

Hi Jm, 
  
 Yes, we need do that. That’s because the style can’t be applied immediately but when the map is refreshing.  
 Thanks, 
  
 Troy

Hi Jm, 
  
 Yes, we need do that. That’s because the style can’t be applied immediately but when the map is refreshing. 
 Thanks, 
  
 Troy