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
Solved! Go to Solution.
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!!
Walter,
try this:
var labelField = "CASENUMBER";
lomaLabels.addFeatureLayer(featureLayerLOMA, lomaLabelRenderer, "{" + labelField + "}" ,{pointPriorities:"AboveLeft"});
Let me know if it works.
Tim
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">
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!!
Im glad you got it figured out
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!
Saloni,
in your code there is an "r" missing here:
http://services1.arcgis.com/hVMNhMnY75fwfIFy/ArcGIS/rest/services/NursingFacilities/FeatureServe
use this link instead
http://services1.arcgis.com/hVMNhMnY75fwfIFy/ArcGIS/rest/services/NursingFacilities/FeatureServer
let me know if this is the issue.
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.