Select to view content in your preferred language

Identify widget

489
1
Jump to solution
11-02-2018 10:34 AM
MarkCooper5
Occasional Contributor II

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 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

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);
                  }
                }

View solution in original post

0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Emeritus

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);
                  }
                }
0 Kudos