Select to view content in your preferred language

javascript 4.6 and labeling FeatureLayer

2765
16
Jump to solution
01-09-2018 02:59 PM
CynthiaKozma
Frequent Contributor

I am new to javascript, but I am trying to put together a fairly simple application with v4.6.  I have a contour layer that I am adding with new FeatureLayer(), but I am having a hard time getting it to label with elevation.  I have tried using a Map Service hosted on our server, as well as, a hosted Feature Layer on AGOL (where the contours are already labeled in both).  No luck with either.  I have read that you can't label a 2D map, does this mean that it is virtually impossible to label the contours??  Is there any work around?  A label would be so much better than a pop-up.  Thanks for the help.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Cynthia,

   That is correct if you need to label on the client then you have to use 3.x currently. If you have the mxd label the contours then when you add the MapImageLayer you will see the labels in 4.x though.

View solution in original post

16 Replies
RobertScheitlin__GISP
MVP Emeritus

Cynthia,

   That is correct if you need to label on the client then you have to use 3.x currently. If you have the mxd label the contours then when you add the MapImageLayer you will see the labels in 4.x though.

ChrisSmith7
Honored Contributor

Are there any updates on when this might come down the pipe? 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Currently (4.8) labeling is supported for Point and Polygon Feature coming from a FeatureServer service on 10.6.1 server (not a MapServer service).

ChrisSmith7
Honored Contributor

I'm currently trying to label a MapServer FeatureLayer (kind of like this example - Add labels to a FeatureLayer | ArcGIS API for JavaScript 4.8 ), but I'm not having much luck. So far, I have:

1) Labeled on the MXD (the service now shows Has Labels: true)

2) Set-up a labelClass, as per the example referenced

3) Set labelsVisible: true in the FeatureLayer instantiation as per FeatureLayer | API Reference | ArcGIS API for JavaScript 4.8 

4) Set labelingInfo: [labelClass], as per the example referenced

5) Set dojoConfig "esri-featurelayer-webgl": 1

6) Double and triple checked spelling for things like the labelingExpressionInfo expression, e.g. "$feature.AreaName", which refers to the field labeled in the MXD

There are no JS errors; I am attempting to label a polygon FeatureLayer. Any ideas for anything I might be missing?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Like I said ONLY FeatureServer services are supported that come from ArcGIS Server 10.6.1 or AGOL It will NOT work with a MapServer url.

ChrisSmith7
Honored Contributor

I kinda figured that would be the answer after re-reading the thread. It wasn't abundantly clear in the known limitations section of the example. Thank you.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

A MapServer will work in 4.9

ChrisSmith7
Honored Contributor

Great! You'd think that would have been available much sooner as a core function...

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

The team has years of work to re-produce to get the 4.x API up to par with 3.x... Think about how many years the 3.x API has been out.