I am adding a TextSymbol renderer to a feaure layer, but I cannot figure out how to make the text dynamic and pull from an attribute. All the examples I found show static text.
this.motoLayer = new FeatureLayer({
url: this.layerURL,
outFields: ["*"],
popupTemplate: this.motoTemplate,
popupEnabled: true,
labelingInfo: this.motoLabel,
labelsVisible: true
});
var symbol = {
type: "text",
color: "black",
haloColor: "white",
haloSize: "2px",
text: "\ue61d ${training_site}",
xoffset: 0,
yoffset: 0,
font: { // autocast as new Font()
size: 12,
family: "CalciteWebCoreIcons",
weight: "bolder"
}
};
this.motoLayer.renderer = {
type: "simple", // autocasts as new SimpleRenderer()
symbol: symbol
};
this.map.add(this.motoLayer);
I tried putting a function in as well and that did not work.
Sorry, I should of mentioned this is a 2D map and 3D is not an option.
Paul,
You can still use LabelClass if you are labeling a MapImageLayer in 2D.
But I am not using a mapimagelayer. I am using a feature layer.
Not much I can do for you then as labeling in 2D is still pretty much unsupported.
Kind of a pain but it could be possible to use a graphics layer instead. Perhaps do a query against the feature service, get all of the features, then loop through each feature giving it the text symbol you want and adding it to the graphics layer.