AnsweredAssumed Answered

Add Link or Button to InfoTemplate For Only One Feature Layer

Question asked by chuckf74 on Nov 5, 2015
Latest reply on Nov 3, 2017 by rscheitlin

Hi All,

 

I have been following this sample: Geoprocessing tool link in popup | ArcGIS API for JavaScript

 

The problem I'm having is that it applies to every feature layer on the map where I've set an infoTemplate and I only want the the extra functionality for one of the layers.  I've been trying to set the content for the infoTemplate and add the link in the setContent function but it's not working.  It prevents the attribute values from displaying and also doesn't doesn't show the link.  I'm puzzled by it because I am able to create a ContentPane.  Why is constructing an anchor any different?  I'm not sure how to solve this problem.

 

Here is some of my code:

 

// infoTemplate for Pour Points

            var wbd10PourPointsInfoTemplate = new InfoTemplate({

                title: "<strong>${CWUAS_NAME}</strong>",

            });

 

            wbd10PourPointsInfoTemplate.setContent(getWbd10PourPointInfoTemplateContent);

 

            function getWbd10PourPointInfoTemplateContent(graphic) {

 

                var content = "<strong>HUC10</strong>: " + graphic.attributes.HUC_10 + " </br>" +

                         "<strong>Square Miles</strong>: " + graphic.attributes.SQM + " </br>" +

                         "<strong>Type</strong>: " + graphic.attributes.PRPT_TYPE + " </br>" ;

 

                // Make a tab container.

                var cp = new ContentPane({

                    content: content

                }, domConstruct.create("div"));

 

          // THIS IS THE SECTION OF CODE THAT PREVENTS ANY VALUES FROM DISPLAYING IN THE CONTENT.  IF THIS IS COMMENTED OUT THEN ALL OF THE ATTRIBUTE VALUES DISPLAY.  IF I MOVER IT OUT OF THIS BLOCK THEN ALL OF THE VALUES DISPLAY AND I ALSO GET THE FUNCTIONAL LINK, BUT THEN IT ALSO SHOWS ON INFO TEMPLATES WHERE I DO NOT WANT TO DISPLAY THE LINK

 

            var link = domConstruct.create("a", {

                "class": "action",

                "id": "statsLink",

                "innerHTML": "Display Watershed", //text that appears in the popup for the link

                "href": "javascript: void(0);"

            }, query(".actionList", window.map.infoWindow.domNode)[0]);

 

            on(link, "click", displayWatershed);

 

 

                return cp.domNode;

            }

Outcomes