0

My working example here does not show the labeling information on features.

 var featureLayer;
 map = new Map("map", {
 basemap: "satellite",
 center: [-46.807, 32.553],
 zoom: 3
 });
 //create a feature collection for the flickr photos
 var featureCollection = {
 "layerDefinition": null,
 "featureSet": {
 "features": [ 
 new Graphic({ 
 geometry: new Point(-47.476661, 42.702002, map.spatialReference),
 attributes: {ObjectID:1 ,title: "my title", description: "my description"} 
 }),
 new Graphic({ 
 geometry: new Point(-46.476661, 31.702002, map.spatialReference),
 attributes: {ObjectID:2 ,title: "my title", description: "my description"} 
 })
 ],
 "geometryType": "esriGeometryPoint"
 }
 };
 featureCollection.layerDefinition = {
 "geometryType": "esriGeometryPoint",
 "objectIdField": "ObjectID",
 "drawingInfo": {
 "renderer": {
 "type": "simple",
 "symbol": {
 "type": "esriSMS",
 "style": "esriSMSCircle",
 "color": [216, 15, 20, 255],
 "size": 18,
 }
 }
 },
 "fields": [{
 "name": "ObjectID",
 "alias": "ObjectID",
 "type": "esriFieldTypeOID"
 }, {
 "name": "description",
 "alias": "Description",
 "type": "esriFieldTypeString"
 }, {
 "name": "title",
 "alias": "Title",
 "type": "esriFieldTypeString"
 }]
 };
 featureLayer = new FeatureLayer(featureCollection, {
 id: 'my-layer'
 });
 
 var labelClass = new LabelClass({
 "labelExpressionInfo": {"value": "{title} title"},
 "labelPlacement":"above-right",
 "symbol": new TextSymbol()
 });
 
 featureLayer.setLabelingInfo([ labelClass ])
 
 
 map.addLayers([featureLayer]);
Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Oct 5, 2020 at 20:28

1 Answer 1

0

You need to indicate the map to show the labels. In order to do this just set Map property showLabels to true. In your code,

map = new Map("map", {
 basemap: "satellite",
 center: [-46.807, 32.553],
 zoom: 3,
 showLabels: true // <- HERE
});
answered Oct 7, 2020 at 4:20

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.