Labels of Lines are shown/hidden by zoom level

1414
13
02-24-2021 04:49 AM
GonzaloMuöoz
Occasional Contributor

Hi,

I'm using following JSON definition for graphics of type line:

StringBuilder labelBuilder = new StringBuilder();
labelBuilder.AppendLine("{");
labelBuilder.AppendLine("\"allowOverrun\": true ,");
labelBuilder.AppendLine("\"allowOverlapOfLabel\": \"allow\" ,");
labelBuilder.AppendLine("\"allowOverlapOfFeatureBoundary\": \"allow\" ,");
labelBuilder.AppendLine("\"allowOverlapOfFeatureInterior\": \"allow\" ,");
labelBuilder.AppendLine("\"priority\": 25 ,");
labelBuilder.AppendLine("\"labelExpressionInfo\": {");
labelBuilder.AppendLine("\"expression\": \"return $feature.Name;\"},");
labelBuilder.AppendLine("\"labelPlacement\": \"esriServerLinePlacementCenterAlong\",");
labelBuilder.AppendLine("\"multiPart\": \"labelLargest\",");
labelBuilder.AppendLine("\"symbol\": {");
labelBuilder.AppendLine("\"color\": [255,255,255,255],");
labelBuilder.AppendLine("\"haloColor\": [51,51,51,255],");
labelBuilder.AppendLine("\"haloSize\": 1.5,");
labelBuilder.AppendLine("\"font\": {\"size\": 10, \"weight\": \"bold\"},");
labelBuilder.AppendLine("\"type\": \"esriTS\"}");
labelBuilder.AppendLine("}");

 

The problem I have is that even by setting the "allowOverlapOfLabel" value to allow, it is hiding the labels at some zoom levels. I add two screenshots attached from the same mapview making just zoom in and zoom out. I've found that this issue is happening only when the label expression is the same, changing them to have different expressions and then they are always visible as expected. Hope this helps.

 

Appart from this, previously I used this link which was very useful:

JSON label class properties—ArcGIS Runtime SDK for .NET | ArcGIS for Developers

But it does not exist anymore and now there's no information regarding JSON definitions of labels.

Regards

Gonzalo

0 Kudos
13 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

That's fine: a value of `none` will ensure that no duplicates should be removed. It will leave all the placed labels on the map regardless of nearby duplicates.

Thanks

0 Kudos
GonzaloMuöoz
Occasional Contributor

Hi,

Yes, that's how It should be but that's not working. This is the reason why we raise the case.

Thanks

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi Gonzalo and Esther,

After further investigation this issue is due to the interaction of duplicate removal and line connection handling.

We will investigate to determine what can be done to improve the line connection behavior for a future release, but in the interim the following option may provide you with a workaround: 

labelBuilder.AppendLine("\"lineConnection\": \"none\" ,");

The default approach for connectable features is to connect them using the option MinimizeLabels, where line geometries with the same label and coincident end vertices should be considered together as a single, continuous geometry when placing labels.

When setting the lineConnection property to a value of None, this will keep one label per line feature geometry.

Thanks

0 Kudos
GonzaloMuöoz
Occasional Contributor

Hi,

I've tested your workaround and it seems to work fine. For us it's enough.

Thanks

Regards

0 Kudos