Hi Team,
RefreshAsync fails to load the correct style when the Layer has same geomety.
Could you please help here to understand why this is happening.
Thanks,
Jayshree
Hi Team,
RefreshAsync fails to load the correct style when the Layer has same geomety.
Could you please help here to understand why this is happening.
Thanks,
Jayshree
Hi Jayshree, can you give us some code snippet, and what do you mean by “fails to load”? it throws exceptions or just returns blank map?
Hi Ben,
I’m working with features (see screenshot below).
When a feature is clicked, we apply some custom styles to the selected feature. However, if there are duplicate features in the feature list, the correct style is not applied to the selected feature when we call RefreshAsync() .
We suspect this is because the result is coming from the overlay cache.
Here is the code snippet:
new ValueStyle(nameof(HighlightStop.IsSelected), new()
{
new ValueItem("0", _geoStyleService.GetThinkGeoLabelStyle(GetPointStyle())),
new ValueItem("1", _geoStyleService.GetThinkGeoLabelStyle(GetSelectedPointStyle())),
})
);
// For point
_featureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(
new ValueStyle(nameof(HighlightStop.IsSelected), new()
{
new ValueItem("0", (ThinkGeo.Core.PointStyle)_geoStyleService.GetThinkGeoStyle(GetPointStyle())),
new ValueItem("1", (ThinkGeo.Core.PointStyle)_geoStyleService.GetThinkGeoStyle(GetSelectedPointStyle())),
})
);
_featureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
return _featureLayer;
Could you please advise whether the overlay cache might be causing this issue, or if there’s a better way to ensure the correct style is applied when dealing with duplicate features?
Thanks,
Jayshree
hi @Jayshree,
I don’t think duplicated features would cause the problem. And what is the overlay cache? Could you tell me more about it?
I created a sample, could you try to update it to reproduce the issue and send it back to me?
SelectedFeaturesSample.zip (3.7 KB)
Regards,
Leo
Hi Leo,
Looks like the TextStyle.CreateSimpleTextStyle() method doesnt allow the duplicate labels to apply the style for second duplicate feature. As it suppress the label style for all the lables matched later.
Because the features have identical text and geometry, ThinkGeo only draws the label for the first one it encounters. The later duplicates have their labels suppressed, so even when a duplicate becomes ‘selected’ its red label never shows unless overlapping labels are allowed
Sample code :
{
var geoTextStyle = TextStyle.CreateSimpleTextStyle(
style.LabelColumnName,
style.LabelFontFamilyName,
style.LabelFontSize,
style.LabelFontStyle.ToGeoDrawingFontStyle(),
GeoColorConverter.FromColorString(style.LabelFontColor));
geoTextStyle.SuppressPartialLabels = false;
geoTextStyle.AllowLineCarriage = true;
geoTextStyle.XOffsetInPixel = style.XOffsetInPixel;
geoTextStyle.YOffsetInPixel = style.YOffsetInPixel;
if (!string.IsNullOrEmpty(style.LabelBackColor) || style.LabelOutlineWidth > 0)
{
var areaStyle = new AreaStyle();
if (style.LabelOutlineWidth > 0)
{
areaStyle.OutlinePen = new GeoPen(GeoColorConverter.FromColorString(style.LabelOutlineColor),
style.LabelOutlineWidth);
}
if (!string.IsNullOrEmpty(style.LabelBackColor))
{
areaStyle.FillBrush = new GeoSolidBrush(GeoColorConverter.FromColorString(style.LabelBackColor));
}
geoTextStyle.Mask = areaStyle;
}
return geoTextStyle;
}```
I tried applying the,
geoTextStyle.DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels;
geoTextStyle.OverlappingRule = LabelOverlappingRule.AllowOverlapping;
But it shows me 2 styles overlapped.

Hope above make sense now.
Thanks,
Jayshree
hi @Jayshree ,
You are absolutely correct. For text, we don’t allow overlapping by default.
Did you upload pictures? I can’t see it, could you re-upload it?
Regards,
Leo
hi @Jayshree ,
Thanks for re-uploading the picture. If OverlappingRule is AllowOverlapping, this is the expected bahavior.
Regards,
Leo