Running into an issue where the .NET Runtime SDK (WPF) map does not seem to be taking any sort of deconfliction strategy for labels into account, and just piling all of them on top of each other.
Map in Runtime SDK:
Map in ArcGIS Pro:
I am aware and appreciate that ArcGIS Pro and Runtime SDK use two very different map displays, but I need to try to understand how to get the two a bit closer than what is being shown. Do I need to explicitly set JSON definitions for labels, does this information not come over in MMPKs?
Solved! Go to Solution.
I will begrudgingly admit that reading the documentation was actually pretty helpful in this case.
Enum LabelOverlapStrategy (arcgis.com)
Setting this to Exclude on all layers gets the map much closer to the behavior in ArcGIS Pro. It's not identical, but it's acceptable.
Update: Upon loading the MMPK, I am subscribing to each layer load and setting the overlap strategy based on the geometry type. This feels counterintuitive, but currently it seems like nothing from the original map comes over from the original map for the label strategies in the MMPK.
foreach (var ld in layer.LabelDefinitions)
{
if (layer.FeatureTable?.GeometryType == GeometryType.Polyline || layer.FeatureTable?.GeometryType == GeometryType.Point)
ld.LabelOverlapStrategy = Esri.ArcGISRuntime.Mapping.Labeling.LabelOverlapStrategy.Exclude;
else
ld.LabelOverlapStrategy = Esri.ArcGISRuntime.Mapping.Labeling.LabelOverlapStrategy.Avoid;
}
This still creates an undesirable effect of some polygon labels just plotting right on top of each other for seemingly no reason.
I will be happy to look into this further and see what's going on 🙂 . Is it possible for you to share your ArcGIS Pro project and MMPK you published. Please specify ArcGIS Pro version that you used to create the Pro project and the MMPK.
@PreetiMaske Yes, I would be happy to do this. The project and MMPK were both created with ArcGIS Pro 3.0.3. Please let me know what the ideal way to share the ARPX and MMPK would be. Thank you!
You can send the files to pmaske@esri.com. It will be helpful if you can also briefly describe your workflow in the email.
Thank you for this incredibly thoughtful and helpful response. I'm very happy to hear that there are people who understand the limitations and differences between the labeling engines in ArcGIS Pro and Runtime SDK and that effort is being put in to making them closer.
@RichardJShepherd wrote:Hi, @KyleGruberItc .Thanks for sharing your data so we could understand why Runtime labeling was ignoring the expected label deconfliction.In this case, the key setting was the label class being set to `Background` labeling in ArcGISPro.`Background` labels are all placed first (avoiding each other), and then all the `Foreground` label classes have their labels placed (avoiding each each other but ignoring, and possibly overlapping, the `Background` labels).
This in particular was a very helpful bit of information. Background label features is not something I have ever used directly. Turning this off is definitely getting the labeling in Runtime to behave more as expected. I suspect running dissolve or a similar tool on the centerline will further help the labeling function as expected, so segments like this:
Look and behave more like this: