Select to view content in your preferred language

Label Placement MapImageLayer vs. FeatureLayer

274
1
2 weeks ago
JeffreyThompson2
MVP Frequent Contributor

I've noticed an annoying difference between how label placement is handled in a MapImageLayer vs. a FeatureLayer. I've used the Web MapViewer to add the same layer twice as both a MapImageLayer and a FeatureLayer. You can see in the image below that the label generated by the FeatureLayer is much farther away than the one from the MapImageLayer. The FeatureLayer labels are too far away in my opinion.

JeffreyThompson2_0-1757010594772.png

The FeatureLayer appears to add a default 10px offset. Adding a -10px offset to both the X and Y gets these labels to line up almost perfectly at all zoom levels.  This extra 10px is consistent for all the labelPlacement  options.

Why is this extra offset being added? Can the labeling engine be adjusted so that the behavior is consistent between the layer types?

GIS Developer
City of Arlington, Texas
1 Reply
Noah-Sager
Esri Regular Contributor

Hi @JeffreyThompson2, thanks for posting your question here. We have 3 different labeling implementations in the ArcGIS Maps SDK for Javascript - 2D featureLayer, 2D mapImageLayer, and 3D. We document the differences in implementation and usage in this guide topic: https://developers.arcgis.com/javascript/latest/labeling/

While we don't explicitly callout the differences between 2D featureLayer and 2D mapImageLayer behavior, the reason we have different fonts is because we have different labeling implementation. For example, mapImageLayer is a server-side only layer. As such, we cannot define a deconfliction strategy for 2D mapImageLayer, only for 2D featureLayer (and associated layers): https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#de...

We constantly work on improving our labeling behavior for every possible use case. Please continue to share your stories and workflows and pain points so we can discuss and address as appropriate.