I have two problems with TextStyle objects on my InMemoryFeatureLayer.
1. Some of the text values do not get displayed until a certain zoom level. Points that are nearby each other are being hidden. However, as per the documentation, I have set the zoomlevel01 ApplyUntilZoomLevel, but it does not seem to take effect.
2. Sometimes when zooming in/out, some of the text values get partially chopped off.
Please see the screenshots for examples.
Here at zoom=8 (my default setting), some text is missing:
When user zooms in to zoom=9, the text is now shown. However, also notice my #2 issue which is the other text being chopped off.
A little background about my code. I read values from my application database and some custom calculations, and create an InMemoryFeatureLayer with a FeatureSourceColumn for my “AQI” value. The TextStyle starting at line 28 is the part which is having trouble.
As you can see I tried setting the GridSize=1… this seems to help a little, but still not all of the text values are displayed.
01.
var inMemoryFeatureLayer =
new
InMemoryFeatureLayer();
02.
inMemoryFeatureLayer.FeatureSource.Open();
03.
// specify the AQI column for the text display
04.
inMemoryFeatureLayer.Columns.Add(
new
FeatureSourceColumn(
“AQI”
,
“String”
, 10));
05.
06.
//Loop through all the point data from my application (_siteAqiData) and add it to the in-memory layer
07.
foreach
(KeyValuePair<PointShape,
double
?> pair
in
_siteAqiData)
08.
{
09.
if
(pair.Value.HasValue)
10.
{
11.
var feature =
new
Feature(pair.Key);
12.
feature.ColumnValues.Add(
“AQI”
, pair.Value.Value.ToString(CultureInfo.InvariantCulture));
13.
inMemoryFeatureLayer.InternalFeatures.Add(feature);
14.
}
15.
}
16.
//Now that all of the data is added we can build an in memory index to make the lookups fast
17.
inMemoryFeatureLayer.BuildIndex();
18.
19.
if
(_createPointStyle)
20.
{
21.
//Create the site point style
22.
PointStyle pointStyle1 = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.White, 4,
23.
GeoColor.SimpleColors.Black, 2);
24.
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(pointStyle1);
25.
}
26.
27.
//***********NOTE******* This is the TextStyle which is having the problem
28.
TextStyle textStyle = TextStyles.CreateSimpleTextStyle(
“AQI”
,
“Arial”
, 12, DrawingFontStyles.Regular, GeoColor.SimpleColors.BrightBlue);
29.
textStyle.HaloPen =
new
GeoPen(GeoColor.StandardColors.White, 3);
30.
textStyle.PointPlacement = PointPlacement.UpperCenter;
31.
textStyle.YOffsetInPixel = 5;
32.
textStyle.DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels;
33.
textStyle.GridSize = 1;
34.
35.
//Apply these styles at all levels and add then to the custom styles for the layer
36.
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
37.
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle);