// get the dom element for my infotemplate as a string var content = []; content[content.length] = '<table cellspacing="0" class="table table-striped table-condensed attr-info">'; if (feature.layerName) { content[content.length] = '<tr><td class="fieldName">SOURCE: </td><td class="fieldName">' + feature.layerName + '</td></tr>'; } /** * Iterate over attributes to get field names. * Ignore certain fields not needing to be displayed * Order matters, so loop forward over keys. **/ var keys = Object.keys(feature.attributes); for (var i = 0, len = keys.length; i < len; i++) { var _key = keys.toLowerCase(); if (!(_key.indexOf('shape') > -1 || _key === 'layername'|| _key === 'objectid' || _key === 'fid')) { var name = keys; content[content.length]= '<tr><td class="fieldName">' + name + '</td><td>${' + name + '}</td></tr>'; } } content[content.length] = '</table>';