Robert,
I took a look at the sample and modified my code to match the sample. When I run the widget, a feature layer does get added to the map; however, nothing gets displayed on the map and the attribute says there's one record, but there are no attributes for that record. Here's what I've done based on the sample:
var featureCollection ={
"layerDefinition": null,
"featureSet": {
"features": [],
"geometryType": "esriGeometryPoint"
}
};
featureCollection.layerDefinition = {
"geometryType": "esriGeometryPoint",
"drawingInfo": {
"renderer": {
"type": "simple",
"symbol": {
"color": [210,105,30,191],
"size": 6,
"type": "esriSMS",
"style": "esriSMSCircle",
"outline": {
"color": [0,0,128,255],
"width": 0,
"type": "esriSLS",
"style": "esriSLSSolid"
}
}
}
},
"fields": [{
"name": "Name",
"alias": "Name",
"type": "esriFieldTypeString"
},{
"name": "Price",
"alias": "Price",
"type": "esriFieldTypeString"
},{
"name": "Rating",
"alias": "Rating",
"type": "esriFieldTypeString"
}]
};
this.featureLayer = new FeatureLayer(featureCollection, {
id: "Restaurants"
});
food.then(lang.hitch(this, function(response){
var i;
var features = [];
for (i = 0; i <= 10; i++){
var name = response.businesses[""+[i]+""].name;
var price = response.businesses[""+[i]+""].price;
var rating = response.businesses[""+[i]+""].rating;
var x1 = response.businesses[""+[i]+""].coordinates.longitude;
var y1 = response.businesses[""+[i]+""].coordinates.latitude;
var markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE,10, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([26,26,26])),new Color([26,26,26]));
var pt = new esri.geometry.Point({"x":x1, "y":y1, "spatialReference":{wkid:4326}});
var attr = {"Name":name, "Price":price, "Rating":rating};
var infoTemplate = new InfoTemplate("Restaurants Near Searched Address","Restaurant Name: ${Name}<br/>Price: ${Price}<br/>Rating: ${Rating}");
var graphic = new esri.Graphic(pt,markerSymbol,attr, infoTemplate);
features.push(graphic);
}
this.featureLayer.add(features);
this.map.addLayer(this.featureLayer);
}), function(error){
console.log(error);
});
}
Thanks,
Michael