Select to view content in your preferred language

Display PDF in InfoWindow

781
3
10-05-2012 09:44 AM
AlexDeVine
Occasional Contributor
Afternoon All,

What I am trying to do should be easy, but either it is not or I am making it hard.

In the website I am constructing, I have a dynamic map service with point feature classes configured with an HTML Popup formatted as a url (esriServerHTMLPopupTypeAsURL). These feature classes have a field named "PDF" that is attributed with the file name for a pdf infosheet about the features so my "prefix" is set as "http://MYSERVER/DEVELOPMENT/WEBSITE/infosheets/" (the path to my infosheets on the webserver) and my "Field" is set as "PDF" (the name of the pdf file). This should mean my service should allow my webapp to see the complete url and display just the pdf in my popup when I click on that feature to fire the identify task.

I can get my identify task to work but it only shows the field contents. I have looked through the forums, api reference, random websites and fee like I have scoured the internet, but I cannot find an example of how to format the infoTemplate to display this information?

Here is my code. Can anyone tell me how this is done? Do I need to change how my url is formatted on the service side? The "verify" in the html popup tab shows exactly what I am after but I don't think I understand how to consume and display it in an infowindow.

function executeIdentifyTasks(evt) {
     identifyTask = new esri.tasks.IdentifyTask(validserviceurl);

     identifyParams = new esri.tasks.IdentifyParameters();
     identifyParams.tolerance = 3;
     identifyParams.returnGeometry = true;
     identifyParams.layerIds = [4];
     identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
     identifyParams.width  = map.width;
     identifyParams.height = map.height;
     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 === 'LEED_Point') {
                var template_info = new esri.InfoTemplate( WHAT DO I DO HERE???);
                feature.setInfoTemplate(template_info);
            }
            return feature;
        });
     });

     map.infoWindow.setFeatures([ deferred ]);
     map.infoWindow.show(evt.mapPoint);
}


Thank you, in advance, for any help!

Alex DeVine
0 Kudos
3 Replies
CraigMcDade
Deactivated User
just to be clear are you trying to show a clickable link to the associated infosheet in your popup?

I did something similar:
var template = new esri.InfoTemplate("",
     "<b>Control Station:</b> <a target='_blank' href=http://gisdev2/surveybenchmarks/scans/${Corner Point Identifier}.pdf>${Corner Point Identifier}</a> <br><b>"
);
"
0 Kudos
AlexDeVine
Occasional Contributor
Hi Craig,

I want the infowindow to only have the pdf displayed when the feature is clicked.

EDIT: Perhaps this cannot be done? I had about a hundred 4" x 4" infosheets made for the features in my database and was just assuming that I could format a popup to contain them. I can make them a jpg if displaying an image in a infowindow popup is easier.

Alex
0 Kudos
__Rich_
Deactivated User
Have a read here:

http://pdfobject.com/markup/index.php

^That should provide enough information to get you started.

There are some gotchas e.g. people with 64-bit browsers won't see your embedded PDF (most people will rely on the Adobe Reader plugin and that's 32-bit only) so you'll need to provide an alternative (e.g. a hyperlink) using the standard fallback mechanism.
0 Kudos