Select to view content in your preferred language

ArcGIS Javascript API v3.21 - Dynamic label placement in feature layer

1750
3
Jump to solution
08-21-2017 07:06 AM
MaximeDemers
Regular Contributor

Is it possible to use dynamic label placement with a feature layer in the javascript API v3.21 ? For instance, if two point features are superposed, I would like to display their labels at different placement.

The LabelClass documentation does not specify this possibility. Is there any solution to achieve this?

Otherwise, is it possible to set a priority to features for labeling. In case two points features are superposed, is it possible to define which feature's label will be displayer on the map?

Thanks

Maxime

Tags (2)
1 Solution

Accepted Solutions
ThomasSolow
Regular Contributor

The documentation says:

Use label classes to restrict labels to certain features or to specify different label fields, symbols, scale ranges, label priorities, and sets of label placement options for different groups of labels.

But I don't see anything about priority in any property or method listed below.  Looking at the source code, it looks to me like priority is based on the label placement.  It's possible I'm missing something though.

My feeling is that if you wanted to do a really good job with this you'd probably have to do it yourself using text symbols and a graphics layer for labels.  Unfortunately I imagine that this would be a lot of work. You would need to re-render labels as the user zooms in and out and the distance between features (in pixels) changes.  You might also have to use standoff lines in order to connect a feature to its label in situations where features are clustered closely.  All of this is doable, but not a small project.

View solution in original post

3 Replies
ThomasSolow
Regular Contributor

The documentation says:

Use label classes to restrict labels to certain features or to specify different label fields, symbols, scale ranges, label priorities, and sets of label placement options for different groups of labels.

But I don't see anything about priority in any property or method listed below.  Looking at the source code, it looks to me like priority is based on the label placement.  It's possible I'm missing something though.

My feeling is that if you wanted to do a really good job with this you'd probably have to do it yourself using text symbols and a graphics layer for labels.  Unfortunately I imagine that this would be a lot of work. You would need to re-render labels as the user zooms in and out and the distance between features (in pixels) changes.  You might also have to use standoff lines in order to connect a feature to its label in situations where features are clustered closely.  All of this is doable, but not a small project.

MaximeDemers
Regular Contributor

Thank you Thomas for your feedback.

I am surprise that labels management  is not more developped in the API. Furthermore, in the javascript API v 4.x, labeling is not yet possible at all in 2D for features layers.

I dont understand why users are not requesting this. Is it because people are only using map services?

0 Kudos
ThomasSolow
Regular Contributor

In my opinion it's definitely a significant missing piece that labels in 2D are not well supported in the JS API.  Even beyond 2D feature layers, I agree with you that labeling is a weak area in general.

0 Kudos