Configuring the My Government Services Pop-up Window

833
4
04-09-2013 10:24 AM
MaryAnnSteinmetz
New Contributor III
I have got the Government Services application up and running with our data and it works great. However, I have a field in the attribute table of the facility point feature class called "Website" that I would like to use as a hyperlink in the info pop-up window. I've scoured the internet and forums here and have not found a solution to do this. I've tried some suggestions here and have not got them to work.  Is it possible to do this with the javascript API?
0 Kudos
4 Replies
DavidMcGill
New Contributor
[ATTACH=CONFIG]23338[/ATTACH]The website name in the attribute field must be formatted   http://www.yoursite.com


here is the code from my application

else if (result.layerName === 'Tower Storage') {
                        var template = new esri.InfoTemplate();
                        var contentString = "";
contentString += "<tr><font color='blue'><b>Monitoring URL:   </b><font color='black'><td><a target='_blank' href=${Monitoring URL}>${Monitoring URL}</a></tr></td><br>";
template.content = contentString;
                        feature.setInfoTemplate(template);
                    }
                    return feature;
0 Kudos
DianaBenedict
Occasional Contributor III
Your best bet will probably be to use the setContent option of the info template.

Once you have instantiated your popup window
You set the map.InfoWindow = popup window that you created
then you can set the InfoWindo.setContent to whatever HTML you should want to create.

The example below assumes that you are setting the content for each graphic that you have selected.

Refer to the ESRI documentation below:

http://help.arcgis.com/en/webapi/javascript/arcgis/jshelp/intro_formatinfowindow.html


function getTextContent(graphic) {
  var commName = graphic.attributes.qSpecies
  var hlink = names[0].split(" ");
  var sciName = hlink[0] + "_" + hlink[1];
  return "<b>" + commName +
    "</b><br /><a target='_blank' href=http://en.wikipedia.org/wiki/"
    + sciName  +">Wikipedia Entry</a>";
}
0 Kudos
MaryAnnSteinmetz
New Contributor III
This is my existing code. This comes straight from the template with our information added accordingly.

// ------------------------------------------------------------------------------------------------------------------------
    // INFO-POPUP SETTINGS
    // ------------------------------------------------------------------------------------------------------------------------
    // Info-popup is a popup dialog that gets displayed on selecting a feature

    //Field for Displaying the features as info window header.
                    InfoWindowHeader: "NAME",

    // Set the content to be displayed on the info-Popup. Define labels, field values, field types and field formats.
    InfoPopupFieldsCollection:
       [
            {
                DisplayText: "Name:",
                FieldName: "NAME"
            },
            {
                DisplayText: "Address:",
                FieldName: "FULLADDR"
            },
            {
                DisplayText: "Contact:",
                FieldName: "CONTACT"
            },
            {
                DisplayText: "Phone:",
                FieldName: "PHONE"
            },
            {
                DisplayText: "Email:",
                FieldName: "EMAIL"
            },
            {
                DisplayText: "Days Open:",
                FieldName: "OPERDAYS"
            },
            {
                DisplayText: "Hours of Operation:",
                FieldName: "OPERHOURS"
            },
            {
                DisplayText: "Website:",               
                FieldName: "<a href= 'AGENCYURL' >AGENCYURL</a> "
            }
      
        ],

    // Set size of the info-Popup - select maximum height and width in pixels.
    InfoPopupHeight: 200,
    InfoPopupWidth: 300,

    // Set string value to be shown for null or blank values.
    ShowNullValueAs: "N/A",
The last field is the one I want to make a hyperlink.
0 Kudos
JordanRogers
New Contributor III
masteinz,

I am working on achieving the same thing and have not had much luck.  Were you able to find a solution?

Thanks,
Jordan
0 Kudos