var template=new esri.InfoTemplate("My Title","${*}");
var template=new esri.dijit.PopupTemplate({ title: result.layerName, fieldInfos: [{ fieldName: "*",visible: true}] });
//generic table of attribures attributeTable: function (atts) { var table = '<table cellspacing="0" cellpadding="2" style="width:100%;">'; for (var i in atts) { var value = atts; var exp = new RegExp(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/); if (exp.test(value)) { value = '<a href="' + atts + '" title="' + atts + '" target="_blank">Hyperlink</a>' } table += '<tr><td><b>' + i + '</b></td><td>' + value + '</td></tr>'; } table += '</table>'; return table } //generic use app.utility.attributeTable(feat.attributes); //used for content of infoWindow it.setContent('<div style="font-size:9px;">' + app.utility.attributeTable(feat.attributes) + '</div>'); //use this one to do the same but also get field aliases for fields of a feature layer featureAttributeTable: function (atts, feature) { var table = '<table cellspacing="0" cellpadding="2" style="width:100%;">'; for (var i in atts) { var alias; dojo.forEach(feature.fields, function (field) { if (field.name === i) { alias = field.alias; } }); var value = atts; var exp = new RegExp(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/); if (exp.test(value)) { value = '<a href="' + atts + '" title="' + atts + '" target="_blank">Hyperlink</a>' } table += '<tr><td><b>' + alias + '</b></td><td>' + value + '</td></tr>'; } table += '</table>'; return table }
var featureLayer = new FeatureLayer("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Boston_Marathon/FeatureServer/0",{ mode: FeatureLayer.MODE_ONDEMAND, outFields: ["*"] }); featureLayer.on("load", function(){ var fieldInfos = array.map(featureLayer.fields, function(field){ return { "fieldName": field.name, "label": field.alias, "visible": true } }); var template = new PopupTemplate({ title: "Boston Marathon 2013", fieldInfos: fieldInfos }); featureLayer.setInfoTemplate(template); }); map.addLayer(featureLayer);
outFields: ["*"]
That solve my problem, thank you!
var infoTemplate = new esri.InfoTemplate("Title Here", "${*}");
Same question: Does ${*} apply to PopupTemplate as well?
Tobias,
Sure here is an example:
var template = new PopupTemplate({ title: "Boston Marathon 2013", description: "{*}" });