I have modified the sample Identify features on a map (http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/find_popup.html) to work with my data. One of my fields is an address to the website (URL). How do I make this active such that a user can click on it and get to the new page? Here is the code that brings up the identify results. It lists the URL, but it is not active. My two fields are Content and URL.
function executeIdentifyTask(evt) { identifyParams.geometry = evt.mapPoint; identifyParams.mapExtent = map.extent; var deferred = identifyTask.execute(identifyParams); deferred.addCallback(function(response) { // response is an array of identify result objects // Let's return an array of features. return dojo.map(response, function(result) { var feature = result.feature; feature.attributes.layerName = result.layerName; if(result.layerName === 'EcoFOCIGOALarval'){ // console.log(feature.attributes.Content); var template = new esri.InfoTemplate("", "${Content} <br/>Link: : ${URL}"); feature.setInfoTemplate(template); } else if (result.layerName === 'AITrawl'){ var template = new esri.InfoTemplate("", "${Content} <br/> Link: : ${URL}"); feature.setInfoTemplate(template); } else if (result.layerName === 'CTDSections'){ var template = new esri.InfoTemplate("", "${Content} <br/> Link: : ${URL}"); feature.setInfoTemplate(template); } else if (result.layerName === 'EBSSurveyGridDis'){ var template = new esri.InfoTemplate("", "${Content} <br/> Link: : ${URL}"); feature.setInfoTemplate(template); } else if (result.layerName === 'SSL2010BiOpZones1'){ var template = new esri.InfoTemplate("", "${Content} <br/> Link: : ${URL}"); feature.setInfoTemplate(template); } return feature; }); });
If there is an easier way, I'm open. This is a very simple application.
This is a snip of code I used based on that example. You will need to change the names I used from my shapefile fields. The "reports" field in the shapefile is a url.
[HTML] function layerTabContent(layerResults, layerName) { var content = ""; switch (layerName) { case "layer1results": content += "<table border='1'><tr><th>School Attending:</th><th>Date:</th><th>General Location:</th><th>Report (Will open in new window)</th></tr>"; for (var i=0, il=layerResults.features.length; i<il; i++) { content+="<tr><td>"+layerResults.features.attributes['HmSchool']+"</td>"; content+="<td>"+layerResults.features.attributes['DateText']+"</td>"; content+="<td>"+layerResults.features.attributes['Location']+"</td>"; content+="<td>"+" <a href=" + layerResults.features.attributes['Reports'] + " target=_blank ;'>Click for Report!</a></td>";
Jacyn, I'm new at this so pardon the confusion. I don't understand how your function layerTabContent(layerResults, layerName) replaces my code or how to implement. Am I using a different example and/or just confused?
Thanks. I'm up and running. I had tried an <a href, but I had the syntax wrong. In addition Aptana confused me as I got a warning message about '<' + '/' + letter not allowed here. Anyway, thanks for you help. It is appreciated.