Select to view content in your preferred language

Attachment photo info returned with ID task

2608
0
03-10-2015 09:05 AM
AdrianMarsden
Honored Contributor

see Find attachments using task in JavaScript API

But I've sort of moved on, so I thought I'd open a new thread.

So, (as every sentence has to start with "so" these days)

I am detecting if my layers have attachments on load with a call to the REST thingy, this is stored in an array, with the array index matching the LayerID

When I go through the records returned in the results dataset of an ID task, I check the layerID of returned record against this array and if it has attachments I then do stuff.

That's my first issue.  I used something like this

                 if (layerHasAttachments) {                      
                        objectId = results.feature.attributes.OBJECTID;
                        t = mapservice2 + "/" + results.layerId.toString();
                        featureLayer = new esri.layers.FeatureLayer(t, {
                            mode: esri.layers.FeatureLayer.MODE_ONDEMAND
                        });
                        //use queryAttachmentInfos to return into array the path of each attachment
                        
                        featureLayer.queryAttachmentInfos(objectId, function (infos) {                          
                            if (infos.length > 0) {                           
                                for (index = 0; index < infos.length; ++index) {
                                    attachmentPath.push(infos[index].url)
                                }
                            }                          
                            console.debug(2);  
                        }
                        );                
                        console.debug(3);
                 }

However, the code carried on before the results came in -0 I get my debug 3, before my debug 2 - so I have issues then deciding if action is needed if a feature has an attachment. - So, first issue, how can I wait for the info from the "queryAttachmentInfos" before moving on?

I had to move on, so every feature in that is in the results dataset that is in a layer that is enabled for attachments has a button next to the result.  This opens a popup where I show the photos (currently we only have photos, so I haven't done the code to detect attachment type).  My code is

 featureLayer.queryAttachmentInfos(objectId, function (infos) {
        imagePopupHTML = "<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml\'><head><title></title></head>'";
        if (infos.length > 0) {
            for (index = 0; index < infos.length; ++index) {
                attachmentPath.push(infos[index].url)
                console.debug(infos[index])
            }
        }
        for (index = 0; index < attachmentPath.length; ++index) {
            imagePopupHTML += "<a href='" + attachmentPath[index] + "'>"
            imagePopupHTML += "<img src='" + attachmentPath[index] + "' style='width:600px'></a></br>"
            
        }
        imagePopupHTML += "<body></body></html>"
        OpenWindowThumb = window.open("", "thumb", "height=" + popY + ", width=" + popX + ",toolbar=no,scrollbars=yes,menubar=no,resizable=yes");
        OpenWindowThumb.document.getElementsByTagName('body')[0].innerHTML = 'Please Wait';
        OpenWindowThumb.focus()
        OpenWindowThumb.document.getElementsByTagName('body')[0].innerHTML = '';
        OpenWindowThumb.document.write(imagePopupHTML);
        
    }
    );

So I get the URL and fling it into an basic HTML page - not elegant, but I am pushed for time and needed to show people that field collected data from Collector can be seen in the office in our browser mapping.

If I use the raw URL for an image in Chrome, it detects the orientation.  IE doesn't.  So I am guessing that some metadata is stored with the image.  I have failed totally in getting it.  I tried a few add on chunks of code, but they didn't return what I was after.  So, that's the next question - Is it possible to query the server to get image rotation info (and other metadata)

Many thanks

ACM

0 Kudos
0 Replies