InfoTemplate not showing all fields

2545
12
10-10-2011 07:11 AM
deleted-user-VeZur_n9o0OZ
Deactivated User
Hi all,

I'm having some difficulty adding a simple info window to my app. I'm following a walkthrough which has told me to create an InfoTemplate and feed it some html. However the resulting pop up only displays a couple of fields: my OBJECTID and the display field used for symbology when the resource was published to the server. I need my pop up to display all/a selection of fields. My code below:



    var content = "${*}";
    //var content = "<b> MSOA Area </b>: ${MSOA_AREA} <br/>";
    // content = content + "<b> Mean Gross Annual Income </b>: ${INCOME_AVG_YEARLY_GROSS} <br/>";
    // content = content + "<b> Target Age Population </b>: ${TARGET_AGE_POP} <br/>";
    // content = content + "<b> Visitor Volume 19th July 2011 </b>: ${MAX_ADJ_VOL_190711} <br/>";
    // content = content + "<b> Visitor Volume 23rd July 2011</b>: ${MAX_ADJ_VOL_230711} <br/>";
    // content = content + "<b> Visitor Volume Difference </b>: ${MAX_ADJ_VOL_DIFF}";

    var infoTemplate = new esri.InfoTemplate("Westfield Origin Destination", content);

    //feature layer
    var flURL = "http://SERVER/ArcGIS/rest/services/Maps/TSB_OD_Operational/MapServer/3";
    featureLayer = new esri.layers.FeatureLayer(flURL, {
     mode : esri.layers.FeatureLayer.MODE_ONDEMAND,
     //outfields : ["MSOA_AREA","INCOME_AVG_YEARLY_GROSS","TARGET_AGE_POP","MAX_ADJ_VOL_190711","MAX_ADJ_VOL_230711","MAX_ADJ_VOL_DIFF"],
     infoTemplate : infoTemplate
    });

    map.addLayers([basemap, featureLayer]);


Anyone have any pointers?

Thanks in advance!
James
0 Kudos
12 Replies
JeffPace
MVP Alum
A tip, then a suggestion

Test the query directly on the rest service.  If you dont specify fields, i think it only returns the objectid and display field.

Try uncommenting your outfields but making it ["*"]

Hi all,

I'm having some difficulty adding a simple info window to my app. I'm following a walkthrough which has told me to create an InfoTemplate and feed it some html. However the resulting pop up only displays a couple of fields: my OBJECTID and the display field used for symbology when the resource was published to the server. I need my pop up to display all/a selection of fields. My code below:



    var content = "${*}";
    //var content = "<b> MSOA Area </b>: ${MSOA_AREA} <br/>";
    // content = content + "<b> Mean Gross Annual Income </b>: ${INCOME_AVG_YEARLY_GROSS} <br/>";
    // content = content + "<b> Target Age Population </b>: ${TARGET_AGE_POP} <br/>";
    // content = content + "<b> Visitor Volume 19th July 2011 </b>: ${MAX_ADJ_VOL_190711} <br/>";
    // content = content + "<b> Visitor Volume 23rd July 2011</b>: ${MAX_ADJ_VOL_230711} <br/>";
    // content = content + "<b> Visitor Volume Difference </b>: ${MAX_ADJ_VOL_DIFF}";

    var infoTemplate = new esri.InfoTemplate("Westfield Origin Destination", content);

    //feature layer
    var flURL = "http://SERVER/ArcGIS/rest/services/Maps/TSB_OD_Operational/MapServer/3";
    featureLayer = new esri.layers.FeatureLayer(flURL, {
     mode : esri.layers.FeatureLayer.MODE_ONDEMAND,
     //outfields : ["MSOA_AREA","INCOME_AVG_YEARLY_GROSS","TARGET_AGE_POP","MAX_ADJ_VOL_190711","MAX_ADJ_VOL_230711","MAX_ADJ_VOL_DIFF"],
     infoTemplate : infoTemplate
    });

    map.addLayers([basemap, featureLayer]);


Anyone have any pointers?

Thanks in advance!
James
0 Kudos
BenReilly
Emerging Contributor
I'm having this problem, too. I've made sure the feature has attributes for all fields, but the only field that will show up is FID. Even using ${*} doesn't work in the InfoTemplate. Putting the layer into ArcGIS.com and enabling a popup there shows all fields correctly.
0 Kudos
deleted-user-VeZur_n9o0OZ
Deactivated User
breilly did you find a solution? I'm still struggling.

I have tried jeff's suggestion with no joy. I've also tried the popup dijit instead.

Jeff - could you expand a little more on this please: "Test the query directly on the rest service"? How would i do that?

James
0 Kudos
BenReilly
Emerging Contributor
No, I haven't really found a solution. I had this problem with multiple feature layers in my map. I solved it (to some degree) by adding each layer as a new function on the map, but one layer still won't display attribute fields properly. Like I said, it's only an error in the javascript API. ArcGIS Online and ArcMap show all attributes.
0 Kudos
deleted-user-VeZur_n9o0OZ
Deactivated User
Ok well I'm in the same boat as you. I have just verified that I can see all attributes in arcgis.com and in ArcMap. Is this something we should report?

Would you mind posting your work around? Do you mean you use map.addlayer() rather than adding all feature layers at once? I'm more than happy to do something hacky.

Thanks,
James
0 Kudos
KellyHutchins
Esri Frequent Contributor
Do you have a service or application url that you can post? Or a public webmap from ArcGIS.com that contains the layer that is causing problems in the ArcGIS API for Javascript?

Ok well I'm in the same boat as you. I have just verified that I can see all attributes in arcgis.com and in ArcMap. Is this something we should report?

Would you mind posting your work around? Do you mean you use map.addlayer() rather than adding all feature layers at once? I'm more than happy to do something hacky.

Thanks,
James
0 Kudos
BenReilly
Emerging Contributor
Ok well I'm in the same boat as you. I have just verified that I can see all attributes in arcgis.com and in ArcMap. Is this something we should report?

Would you mind posting your work around? Do you mean you use map.addlayer() rather than adding all feature layers at once? I'm more than happy to do something hacky.

Thanks,
James


I used this to add each layer individually. It's added content in the InfoTemplate for all but one problem layer.

   function showFood(){
   
   var Foodinfo = new esri.InfoTemplate("<b>${Name}</b>", "${op1}");
   
    Food = new esri.layers.FeatureLayer("http://studentgisserver.uww.edu/ArcGIS/rest/services/campus/MapServer/6", {
        mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
        outFields: ["*"],
  infoTemplate: Foodinfo
        });
  map.addLayer(Food);
   }
   
   function showRec(){
   
   var recinfo = new esri.InfoTemplate("Recreation Area", "<b>${Name}</b>")
   
    Rec = new esri.layers.FeatureLayer("http://studentgisserver.uww.edu/ArcGIS/rest/services/campus/MapServer/2", {
        mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
        outFields: ["*"],
  infoTemplate: recinfo
        });
  Rec.setOpacity(0.55);
  map.addLayer(Rec);
   }
0 Kudos
KellyHutchins
Esri Frequent Contributor
Ben,

I just ran a quick test using your services and I can see the fields you specify in the info template. Is there another field you were trying to view?

Here's a link where you can see the test running:
http://jsfiddle.net/khutchins/KW55w/
0 Kudos
BenReilly
Emerging Contributor
That was how I got my other layers to work- when they were all in the same init function, only one field showed up. This is the layer I can't get to work:

function parkinginit(){
  
  var parkinfo = new esri.InfoTemplate("Parking Info", "${*}")
  
  parking = new esri.layers.FeatureLayer("http://studentgisserver.uww.edu/ArcGIS/rest/services/campus/MapServer/5", {
  mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
  outfields: ["*"],
  infoTemplate: parkinfo
  });

  map.addLayer(parking);
}


I can't see anything different or wrong from any of the other layers that do work. Here's the example on ArcGIS Online. As you can see, it can find the fields here.

http://bit.ly/oN1UUr

Here's a web example showing how the parking lot infotemplate does not work properly.

http://studentgisserver.uww.edu/javamapsearch.html
0 Kudos