FeatureLayer labeling not working on 2D for JS API 4.5

2554
9
Jump to solution
11-12-2017 04:21 AM
EmreDelioglu
New Contributor

Hi,

i am using arcgis js api 4.5. 

i added new FeatureLayer with LabelClass to my application. but labels were not visible in MapView. if change to SceneView , labels were visible. 

what is wrong? MapView has any options for labeling?

i attached the sample code. the sample code extended this sample.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Emre,

  Right on the LabelClass docs you will find this:

Known Limitations

There is no support for labeling in 2D. Labeling is only supported in 3D SceneViews.

View solution in original post

9 Replies
RobertScheitlin__GISP
MVP Emeritus

Emre,

  Right on the LabelClass docs you will find this:

Known Limitations

There is no support for labeling in 2D. Labeling is only supported in 3D SceneViews.

MathiasDahl
New Contributor III

Hi,

I also experienced this today. I spent a few hours trying to get labels to work. I have used them in the 3.x API and know they can be tricky to work correctly so I thought I was not using the API correctly. Some hours later I noticed that little comment  Oh well... This is not the first time with the 4.x API, I'm afraid. I understand it can take a long time to make it as feature rich as the old one. It's very tempting to use the new API, for many reasons, but you get "burnt" when "little" things (I have of course no idea on how hard labels is to get working on 2D in 4.x) like this does not work.

Could we get any comment from someone from Esri on if adding this is on the backlog, and if so when it might be released? I have been thinking of using the workaround of duplicating each graphic I add to the map (to have two feature layers, really) where one have a text symbol and the other a "dot", but it feels like quite a hack...

Thanks!

/Mathias

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mathias,

  Well until the 4.x API contains the ability to label in 2D then you limited to what is available. You are aware that you can have labeling for a layer if you define the labeling in the map service and then use a MapImageLayer and not a FeatureLayer right? The other option is like you said use the workaround you suggested. One of the main reasons that feature labeling is used on the client side is for when you give the user the ability to change the label field dynamically. If you do not need that ability then using a MapImageLayer is the obvious choice.

0 Kudos
MathiasDahl
New Contributor III

Hi, thanks for the comment. Yes, I am aware of "server-side labelling". I did not mention here that in my current scenario, I am "plotting" the features manually. I.e. they don't come from the feature service/server (I have made other maps with uses feature services properly, using the 3.x API). So I am either using a FeatureLayer with the source property set when creating it, or I am using a graphics layer, but it does not support labelling at all.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

OK, then like you mentioned the two graphics with different symbols is your only option now then. 

0 Kudos
MathiasDahl
New Contributor III

Yes, looks like it. I actually took the plunge and tried it out and it turns out it was both easy and performant. SInce I am using a graphics layer I can use the same layer for the "real" (marker) symbols as well as the "labels" (text symbols). More or less it's a handful of extra lines of code when I already have my coordinates at hand. I experimented with 1000 symbols (times 2, really, because of the duplication of the symbols) and toggling on and off "labels" (by removing the text symbols I toggle them off) takes less than a second. I also tried with 10,000 (times 2) symbols and then the API/browser/CPU start to get on its knees (it did work though, no crashes), but that is not a very relevant scenario in my case.

Thanks for the comments.

0 Kudos
RaisaTABOUGUIA1
New Contributor

Hello,
I'm using the JS 4.7 version, and I'm having the same problem. I can not display labels on a featureLayer for a 2D view.  I need this option because the final client of the application should be able to bring changes on the featureLayer (that's why it is not usefull for us to use MapImageLayers). Is there any workaround to manage this ?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Raisa,

  The ability to do that is just not there yet in 4.x and there is not know workaround.

0 Kudos
xavierlhomme
Occasional Contributor

Hi

  I need this functionnality too. Do you have a release date to communicate?

best regards

Xavier Lhomme
GIS Architect / ESIRI Expert
0 Kudos