Select to view content in your preferred language

3.10 label layer change not working?

2961
7
Jump to solution
09-04-2014 06:07 AM
WalterEralio
Occasional Contributor

Upgrading to 3.10 I found in the documentation at what's new ( What's new in Version 3.10 | Guide | ArcGIS API for JavaScript )

Label layer changes: Labeling expressions no longer use ${field} syntax but now use {field}. In other words, popup template syntax instead of info template syntax.

I've changed it accordingly and the {CASENUMBER} text is displayed instead of the value

lomaLabels.addFeatureLayer(featureLayerLOMA, lomaLabelRenderer, "{CASENUMBER}" ,{pointPriorities:"AboveLeft"});

I really need this since I'm struggling with ${} been confused with a TAG and my program blows out with the error org.apache.jasper.JasperException: The attribute prefix CASENUMBER does not correspond to any imported tag library

0 Kudos
1 Solution

Accepted Solutions
WalterEralio
Occasional Contributor

IT WAS WORKING FINE!! my bad!! I was hosting the API and replacing the HOST name I accidentally post to the old api (3.7)
TIM WITT: THANKS FOR YOUR HELP!! and quick response!!

View solution in original post

0 Kudos
7 Replies
TimWitt2
MVP Alum

Walter,

try this:

var labelField = "CASENUMBER";

lomaLabels.addFeatureLayer(featureLayerLOMA, lomaLabelRenderer, "{" + labelField + "}" ,{pointPriorities:"AboveLeft"});

Let me know if it works.

Tim

TimWitt2
MVP Alum

Also make sure that you changed the api to 3.10

<script src="//js.arcgis.com/3.10/"></script>

<link rel="stylesheet" href="https://community.esri.com//js.arcgis.com/3.10/js/esri/css/esri.css">

WalterEralio
Occasional Contributor

IT WAS WORKING FINE!! my bad!! I was hosting the API and replacing the HOST name I accidentally post to the old api (3.7)
TIM WITT: THANKS FOR YOUR HELP!! and quick response!!

0 Kudos
TimWitt2
MVP Alum

Im glad you got it figured out

0 Kudos
JssrRR
by
Frequent Contributor

Tim,

I need some help figuring this out, I am trying to do something similar, but once I add the label layer, the feature layer is not showing up.

I have added this, among other required

require ([ "esri/layers/LabelLayer",

  "esri/renderers/ScaleDependentRenderer"

function( LabelLayer, ScaleDependentRenderer

        var featureLayer = new FeatureLayer("http://services1.arcgis.com/hVMNhMnY75fwfIFy/ArcGIS/rest/services/NursingFacilities/FeatureServe                    mode: FeatureLayer.MODE_ONDEMAND,

          outFields: [labelField]

        });

      var labelField = "FacilityID";

      var NFColor = new Color("#444")

  // create a text symbol to define the style of labels

        var NFLabel = new TextSymbol().setColor(NFColor);

        NFLabel.font.setSize("12pt");

        NFLabel.font.setFamily("arial");

        NFLabelRenderer = new SimpleRenderer(NFLabel);

        var labels = new LabelLayer({

            id: "labels" });

        // tell the label layer to label the Nursing facility feature layer

        // using the field named "FacilityID"

        labels.addFeatureLayer(featureLayer, NFLabelRenderer, "{" + labelField + "}");

        // add the label layer to the map

      map.addLayer(labels);

     // scale dependent renderer for NF labels

        var NFRenderer = new SimpleRenderer(NFLabel);

        var NFScaleDependent = new ScaleDependentRenderer({

          rendererInfos: [{

            renderer: NFRenderer,

            minScale: 500000,

            maxScale: 1         

          );

        });

        var NFOptions = { pointPriorities: "AboveCenter" };

        labels.addFeatureLayer(featureLayer, NFScaleDependent, "{FacilityID}", NFOptions);

       FeatureLayer.setRenderer(NFRenderer);

        map.addLayer(featureLayer);

The feature layer itself is not loading, something is missing or I am not doing it right, any help will be appreciated.

Thanks!

0 Kudos
TimWitt2
MVP Alum
0 Kudos
JssrRR
by
Frequent Contributor

Tim,

I added the correct link, but that did not help, probably something else needs to corrected, still working on it.

Thanks for the help.

0 Kudos