I have created an app web map that has over 100 layers in (customer needs all of them). As it would take a very long time to add all the layers and format the fields, I have just not clicked in the 'Only these' button so it uses all (visible) layers in the map.
The identify function works great but the results of the identify show all fields in the service. Also it shows the field name rather than the alias from the map service. My questions are:
1. Is it possible for it to return just the fields from the popup? If not I can change the mxd, although this change it for all users of the service.
2. Can the results show the alias rather than the field name?
Thanks
Solved! Go to Solution.
Mark,
1. Is likely possible I don't have time now to investigate or implement.
2. Yes you can add this code to get the alias.
Add new function (lines 1-11) add lines (32 & 33) to showQueryResults function.
_getAlias: function (fldName, layer) {
var field = layer.fields;
var item;
for (var i in field) {
item = field[i];
if (item && item.name && item.name.toLowerCase() === fldName.toLowerCase() && item.alias) {
return item.alias;
}
}
return fldName;
},
...
//@line 2022
}else{
if(this.config.layers.onlythese === false){
var currentLayer = this.map.getLayer(fIds[i]);
this.resultFound = true;
for (fld in obj){
if(fld.toUpperCase() !== 'SHAPE'){
try{
value = obj[fld] ? String(obj[fld]) : '';
} catch (error) {
value = '';
}
if(this.replacenullswithemptystring && (value === 'Null' || value === '<Null>')){
value = '';
}
if (value.toLowerCase().indexOf("http") > -1) {
value = "<a href='" + value + "' target='_blank'>" + value + "</a>";
}
var tfldAlias = this._getAlias(fld, currentLayer);
content = content + this.resultFormatString.replace('[attribname]', tfldAlias).replace('[attribvalue]', value);
}
}
Mark,
1. Is likely possible I don't have time now to investigate or implement.
2. Yes you can add this code to get the alias.
Add new function (lines 1-11) add lines (32 & 33) to showQueryResults function.
_getAlias: function (fldName, layer) {
var field = layer.fields;
var item;
for (var i in field) {
item = field[i];
if (item && item.name && item.name.toLowerCase() === fldName.toLowerCase() && item.alias) {
return item.alias;
}
}
return fldName;
},
...
//@line 2022
}else{
if(this.config.layers.onlythese === false){
var currentLayer = this.map.getLayer(fIds[i]);
this.resultFound = true;
for (fld in obj){
if(fld.toUpperCase() !== 'SHAPE'){
try{
value = obj[fld] ? String(obj[fld]) : '';
} catch (error) {
value = '';
}
if(this.replacenullswithemptystring && (value === 'Null' || value === '<Null>')){
value = '';
}
if (value.toLowerCase().indexOf("http") > -1) {
value = "<a href='" + value + "' target='_blank'>" + value + "</a>";
}
var tfldAlias = this._getAlias(fld, currentLayer);
content = content + this.resultFormatString.replace('[attribname]', tfldAlias).replace('[attribvalue]', value);
}
}