I'm teaching myself GIS Web Development. Below is a snippet of code for an Identify tool i'm building. Not a part of any project to be implemented. Just for learning. None of the attributes for the fields used as content parameters on line 25 display with exception of the first two that i have set to display in bold. if I use
var SL_infoTemplate = new esri.InfoTemplate("Sewer Lines", "${*}");
they all display. Also, the arguments on line 17 work with exception of the "Install Date"
Can anyone explain this to me? What am I missing?
// dojo.require() calls the necessary map-related references(libraries? modules?) from the API library to the application: dojo.require("esri.map"); dojo.require("esri.layers.featurelayer"); dojo.require("esri.InfoTemplate"); dojo.require("esri.dijit.Legend"); function startup() { // create the map object and load it in "mymap" div element var map = new esri.Map("mymap",{ // Parameters below added by me based on argis js API center: [-92.315097, 34.733316], zoom: 16, basemap: "topo", }); //load the manhole layer into an object var lyrManholes = new esri.layers.FeatureLayer("http://app7:6080/arcgis/rest/services/MoreLayers/MapServer/0", {outFields: ["*"]}); //Indetify the Manhole and display attributes var tMH = "<b>${MH_NO}</b><br>" + "Depth: ${MHDPTH}<br>" + "Install Date: ${INSDATE}<br>" + "Unit Type: ${UNITTYPE}<br>" + "ServStat? ${SERVSTAT}<br>"; //create the MH_infoTemplate object and pass the template var MH_infoTemplate = new esri.InfoTemplate("Manholes", tMH); //assign the MH_infoTemplate so it applies on every feature in this layer lyrManholes.setInfoTemplate(MH_infoTemplate); //load the sewer lines layer into an object var lyrSewers = new esri.layers.FeatureLayer ("http://app7:6080/arcgis/rest/services/MoreLayers/MapServer/1", {outFields: ["*"]}); //Indetify the Sewer lines and display attributes var tSL = "<b>${UPS_MH}</b>" + "<b> - </b>" + "<b>${DWN_MH}</b><br>" + "Pipe Length: ${PIPELEN}<br>"; //create the info template object and pass the template var SL_infoTemplate = new esri.InfoTemplate("Sewer Lines", tSL); //assign the infotemplate so it applies on every feature in this layer lyrSewers.setInfoTemplate(SL_infoTemplate); // Add the legend. map:map is which map will have the lengend. "mylegend" is the legend div element. var legend = new esri.dijit.Legend({map: map}, "mylegend"); legend.startup(); //Add the layers to the map .addLayer(lyrSewers); map.addLayer(lyrManholes); } //dojo.addOnLoad(startup) will tell the browser to call the startup function upon starting.
Brad,
Are you sure that those are the correct field names for those layers (CaSe is important)?
Field names are correct
I originally had about 7 fields and took it down to 3 total to make it easier to debug.
I stand corrected. When I choose display all field attributes they do not all display as can be seen in the screen capture. Both PIPELEN and PIPEDIA are both "double" data types.
Brad,
If you are just learning JS API then you should not be learning Legacy style coding (which is what you have right now). You need to be learning AMD Style coding. Here is a sample with your layers using AMD and I have simplified the info template text:
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>Info Window Lite</title> <link rel="stylesheet" href="https://js.arcgis.com/3.15/esri/css/esri.css"> <style> html, body, #mapDiv { height: 100%; margin: 0; padding: 0; } </style> <script src="https://js.arcgis.com/3.15/"></script> <script> require([ "esri/map", "esri/dijit/InfoWindow", "esri/InfoTemplate", "esri/layers/FeatureLayer", "dojo/dom-construct", "dojo/domReady!" ], function( Map, InfoWindow, InfoTemplate, FeatureLayer, domConstruct ) { var map = new Map("mapDiv", { basemap: "topo", center: [-92.315097, 34.733316], zoom: 16, basemap: "topo" }); var infoWindow = new InfoWindow(null, domConstruct.create("div", null, null, map.root)); infoWindow.startup(); map.setInfoWindow(infoWindow); var template = new InfoTemplate(); var tMH = "<b>${MH_NO}</b><br>Depth: ${MHDPTH}<br>Install Date: ${INSDATE}<br>Unit Type: ${UNITTYPE}<br>ServStat? ${SERVSTAT}"; template.setTitle("Manholes"); template.setContent(tMH); //add a layer to the map var lyrManholes = new FeatureLayer("http://app7:6080/arcgis/rest/services/MoreLayers/MapServer/0", { infoTemplate:template, outFields: ["*"] }); map.addLayer(lyrManholes); var template2 = new InfoTemplate(); var tSL = "<b>${UPS_MH} - ${DWN_MH}</b><br>Pipe Length: ${PIPELEN}"; template2.setTitle("Sewer Lines"); template2.setContent(tSL); //add a layer to the map var lyrSewers = new FeatureLayer("http://app7:6080/arcgis/rest/services/MoreLayers/MapServer/1", { infoTemplate:template2, outFields: ["*"] }); map.addLayer(lyrSewers); }); </script> </head> <body> <div id="mapDiv"></div> </body> </html>
Yeah, I see that now. And the original problem isn't as broad as I thought. The attributes show up sometime. It may have something to do with my IDE. On to AMD.