I am trying to show the infowindow of a point when the specific point's OBJECTID is clicked on in a table. I am able to get a blank infowindow to show, but no title or attributes are displayed. Could someone please direct me to what I am missing? The function that I am currently calling is attached. Any help is greatly appreciated! Thanks in advance.
Wesley,
I had to put together a sample to figure out what was going wrong. Here is your corrected function, lines 13, 17 and 18 are the fix (use InfoTemplate instead of PopupTemplate).
function selectSite(e) { // select the feature var queryGrid = new Query(); queryGrid.objectIds = [e.target.innerHTML]; sitesQuery.selectFeatures(queryGrid, featureLayer.SELECTION_NEW, function(result) { if (result.length > 0) { // re-center the map to the selected feature var pt = result[0]; var ptGeom = result[0].geometry; var factor = 10; //some factor for converting point to extent var newExtent = new Extent(ptGeom.x - factor, ptGeom.y - factor, ptGeom.x + factor, ptGeom.y + factor, ptGeom.spatialReference); map.setExtent(newExtent); var template = new InfoTemplate({title: "Site"}); template.setContent("<tr><b>Facility: </b><td>${FAC_NAME}</tr><br><tr><b>Address: </b><td>${ADDRESS_1} ${CITY}, ${STATE_CODE} ${ZIP_CODE}<br><tr><b>Contamination Type: </b><td>${CONTAM_TYPE}</tr></td><br><tr><b>Latitude: </b><td>${LAT_DECIMAL}</tr></td><br><tr><b>Longitude: </b><td>${LONG_DECIMAL}</tr>"); pt.setInfoTemplate(template); map.infoWindow.setFeatures([pt]); map.infoWindow.show(ptGeom); } else { alert("Select an OBJECTID to Zoom to Feature"); }; }); }
Yes, all necessary attributes are present and will print to the console.
So does the sitesQuery FeatureLayer have FAC_NAME, ADDRESS_1, etc, etc in its out fields?
Have you tried to print the pt.attributes to the console?
Thanks for your response. Yes, e.target.innerHTML returns the proper ObjectID. I also checked the ObjectID of the associated graphic by using alert(pt.attributes.OBJECTID);. Something seems to be missing when creating the infowindow that prevent the attributes from displaying.
Are you sure that "e.target.innerHTML" is actually getting the ObjectID?
Did you try a console.info(e.target.innerHTML);
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.