I have featureLayer that is loaded as a FeatureServer so I can add features to it. Adding to the featureLayer through applyEdits adds graphics to this layer. I'd also like this layer to be a source for my LabelLayer, so the features I'm adding have a label based on CITY attribute I'm populating.
When I first add the feature to my layer, the text label appears as expected. However, once I pan, the label changes from the CITY attribute to appearing as 'undefined'.
The CITY attribute is present in layer, I can see it in ArcCatalog, so I know it has values.
app.bufferLayer = new FeatureLayer(config.pathName + "/arcgis/rest/services/bufferAnalysis/FeatureServer/0" ,{ id:"bufferLayer"} ) var textColor = new Color("#FF0000"); var cityText = new TextSymbol(); cityText.setColor(textColor); cityText.font.setSize("7pt"); var cityLabelRenderer = new SimpleRenderer(cityText); cityLabelLayer = new LabelLayer({ id: "cityLabels" }); cityLabelLayer.addFeatureLayer(app.bufferLayer, cityLabelRenderer, "${CITY}"); app.map.addLayers([featureLayer,cityLayer,app.bufferLayer,app.graphicsLayer,cityLabelLayer]);
The is based on the example Select with Feature Layer | ArcGIS API for JavaScript , but instead of just a graphic added to the map, I want to save the circle I'm generating, along with the summary statistics as a new feature in my featureLayer. It seems like my edits are getting applied, but I don't understand why the labels first appear, then disappear. Is this not a valid use of labelLayer?
Solved! Go to Solution.
I see what I did wrong. You have to have some outFields specified in your FeatureLayer definition or this doesn't work. I always think the default is outFields:['*'], but the default is no fields get returned.
app.bufferLayer = new FeatureLayer(config.pathName + "/arcgis/rest/services/DPS/VetComm_bufferAnalysis/FeatureServer/0" ,{
id:"bufferLayer",
outFields:['*']
}
)
I see what I did wrong. You have to have some outFields specified in your FeatureLayer definition or this doesn't work. I always think the default is outFields:['*'], but the default is no fields get returned.
app.bufferLayer = new FeatureLayer(config.pathName + "/arcgis/rest/services/DPS/VetComm_bufferAnalysis/FeatureServer/0" ,{
id:"bufferLayer",
outFields:['*']
}
)