AnsweredAssumed Answered

Adding links to Map Popup(infoWindow)

Question asked by franklin.alexander on Mar 11, 2019
Latest reply on Mar 11, 2019 by rscheitlin

I want to add a couple of links the the bottom of a popup for a result feature. I was able to do this for the popup that shows when clicking on one of the results in the Query widget results table. This is unfortunately a lot harder to do for the popup that shows when the feature is clicked on the map (the results are a point layer). I cannot find where in the application that the actual 'onClick' event occurs. The links must be added AFTER the point on the map is clicked, so adding them to the template is not as option. This is because the links are dependent on the field value for the clicked feature. 

 

For the Query widget popup, I added two functions in the utils.js file:

 

addViewLinkToInfoWindow: function() {
            var attSect = query('.attachmentsSection', this.domNode)[0];
            var attList = query('.attachmentsSection ul', this.domNode)[0];
            var titleDiv = query('.attachmentsSection div', this.domNode)[0];
            html.removeClass(attSect, 'hidden');
            titleDiv.parentNode.removeChild(titleDiv);
            var viewurl = "https://fwc-spdev5.fwc.state.fl.us/FRRP/Sites/Details/3020";
            var viewTransect = domConstruct.toDom('<li class="viewSite"><strong><a href="' + viewurl + '" target="_blank">View Site Details</a></strong></li>');
            domConstruct.place(viewTransect, attList);
            //console.log("attribute list ", attList);
      },

addTransectLinksToInfoWindow: function() {
            var attSect = query('.attachmentsSection', this.domNode)[0];
            var attList = query('.attachmentsSection ul', this.domNode)[0];
            var titleDiv = query('.attachmentsSection div', this.domNode)[0];
            html.removeClass(attSect, 'hidden');
            titleDiv.parentNode.removeChild(titleDiv);
            var addurl = "https://fwc-spdev5.fwc.state.fl.us/FRRP/Transects/Add/3020";
            var viewurl = "https://fwc-spdev5.fwc.state.fl.us/FRRP/Sites/Details/3020";
            var addTransect = domConstruct.toDom('<li class="addTransect"><strong><a href="' + addurl + '" target="_blank">Add or Edit Transect</a></strong></li>');
            var editTransect = domConstruct.toDom('<li class="viewSite"><strong><a href="' + viewurl + '" target="_blank">View Site Details</a></strong></li>');
            domConstruct.place(addTransect, attList);
            domConstruct.place(editTransect, attList);
            //console.log("attribute list ", attList);
      },

 

And then I called them in the SingleQueryResult.js file in the _onResultsTableClicked (event)

if(transectNum === 2) {
     queryUtils.addViewLinkToInfoWindow();
     this.map.infoWindow.show(centerPoint);
} else {
      queryUtils.addTransectLinksToInfoWindow();
      this.map.infoWindow.show(centerPoint);
}

 

If anyone knows where I can add this code so that I can add the same links to the popup resulting from a feature click, can you please let me know. Popups(infoWindows) can be confusing! lol

 

Thank you! 

Outcomes