Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showAttachments not honored in Identify.js against MapService #177

Closed
kcarrier opened this issue Aug 22, 2014 · 54 comments
Closed

showAttachments not honored in Identify.js against MapService #177

kcarrier opened this issue Aug 22, 2014 · 54 comments
Assignees

Comments

@kcarrier
Copy link

REST Service : http://engineer05.gomvo.org/arcgis/rest/services/SP/RoadRecords/MapServer

LayerId: 13

identify.js

roadrecords: {
            13: {
                title: 'Road Records Index',
                showAttachments: true,
                description: [
                    '<table class="attrTable">',
                    '<tr valign="top">',
                    '<td class="attrName">Document :</td>',
                    '<td class="attrValue">{Document}</td>',
                    '</tr>',
                    '</table>'
                ].join('')
            }

viewer.js

{
            type: 'dynamic',
            url: 'http://engineer05.gomvo.org/arcgis/rest/services/SP/RoadRecords/MapServer',
            title: 'Road Records',
            noLegend: true,
            collapsed: true,
            identifyLayerInfos: {
                layerIds: [1, 3, 5, 7, 9, 11, 13]
            },
            options: {
                id: 'roadrecords',
                opacity: 1.0,
                visible: true
            }

Attachments are not showing in popup.

@tmcgee
Copy link
Member

tmcgee commented Aug 23, 2014

@kcarrier, I don't believe this is a CMV issue. It is my understanding that showAttachments is only available in the ArcGIS JavaScript API for feature layers, not for dynamic layers. CMV doesn't do anything with the identify template you provide other than pass it along to the PopupTemplate. Here's what the docs say about using showAttachments in defining the popup template

@DavidSpriggs
Copy link
Member

@kcarrier @tmcgee Yes, it has to be a feature layer when added to the map. Try adding it via the operational layers array in viewer.js as a feature layer using:
http://engineer05.gomvo.org/arcgis/rest/services/SP/RoadRecords/MapServer/13
Then the showAttachments should work in your template definition.

@kcarrier
Copy link
Author

@tmcgee & @DavidSpriggs - All I agree the documentation says one thing but I think this code might disprove that theory. You will need to zoom all the way in to get the popup to work, but the attachment comes through here, thoughts?

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <!--The viewport meta tag is used to improve the presentation and behavior of the
    samples on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>
        San Francisco
    </title>

    <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/dojo/dijit/themes/claro/claro.css">
    <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">
    <style>
        html, body {
            height: 100%;
            width: 100%;
            margin: 0;
            padding: 0;
        }

        .esriScalebar {
            padding: 20px 20px;
        }

        #map {
            padding: 0;
        }
    </style>

    <script src="http://js.arcgis.com/3.10/"></script>
    <script>
        var map;

        require([
          "esri/config",
          "esri/map",
          "esri/dijit/Popup",
          "esri/dijit/PopupTemplate",
          "esri/layers/ArcGISDynamicMapServiceLayer",
          "esri/symbols/SimpleMarkerSymbol",
          "esri/tasks/GeometryService",
          "dojo/dom-construct",
          "dojo/parser",
          "esri/Color",
          "dijit/layout/BorderContainer",
          "dijit/layout/ContentPane",
          "dojo/domReady!"
        ],
          function (
            esriConfig, Map, Popup, PopupTemplate, ArcGISDynamicMapServiceLayer,
            SimpleMarkerSymbol, GeometryService, domConstruct, parser, Color
          ) {

              parser.parse();

              esriConfig.defaults.geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

              var popupOptions = {
                  markerSymbol: new SimpleMarkerSymbol("circle", 32, null,
                    new Color([0, 0, 0, 0.25])),
                  marginLeft: "20",
                  marginTop: "20"
              };
              //create a popup to replace the map's info window
              var popup = new Popup(popupOptions, domConstruct.create("div"));

              map = new Map("map", {
                  basemap: "topo",
                  center: [-84.259420, 39.750745],
                  zoom: 17,
                  infoWindow: popup
              });

              var popupTemplate = new PopupTemplate({
                  title: "TEST",
                  fieldInfos: [
                    {
                        fieldName: "STR_NAME",
                        visible: true,
                        label: "Type"
                    },
                    {
                        fieldName: "HyperLink",
                        visible: true,
                        label: "Hyperlink"
                    }
                  ],
                  showAttachments: true
              });

              var demographicsLayer = new ArcGISDynamicMapServiceLayer("http://engineer05.gomvo.org/arcgis/rest/services/SP/RoadRecords/MapServer");
              demographicsLayer.setInfoTemplates({
                 13: { infoTemplate: popupTemplate }
              });
              map.addLayer(demographicsLayer);
          });
    </script>
</head>

<body class="claro">
    <div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'"
         style="width: 100%; height: 100%; margin: 0;">
        <div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'"
             style="border:1px solid #000;padding:0;">
        </div>
    </div>
</body>

</html>

@DavidSpriggs
Copy link
Member

@kcarrier The behaviour in CMV is due to the way we set the templates on the features independent of the layer. In your example it is set on the actual layer. I will investigate and see if we can fix this.

@tmcgee
Copy link
Member

tmcgee commented Aug 25, 2014

'setInfoTemplate' was just added to Dynamic and Tile layers at version 3.10 so it sounds like the documentation has some catching up to do. An infoTemplates property for the layer configuration options was added as well.

There has potential to greatly simplify the Identify widget using infoTemplates at the layer level. However, adding the infoTemplate to the dynamic layer like this as opposed to the returned features has an undesirable side effect of interfering with other map tools that use a click (Edit, Draw, Measure, StreetView, Directions). This occurs in some instances today with feature layer infoTemplates (and other graphics such as features returned from a FInd). We addressed it for the Edit widget and feature layer infoTemplates. Alternative strategies have been discussed for a centralized approach instead of custom code for each individual widget.

In the example provided, it is not clear to me what triggers the identify at just the highest zoom level. It will require some investigation to determine when to let the API handle the map click and when to do it the "CMV way". In my opinion, more documentation of this behavior from ESRI is required before we should support this behavior.

Another consideration is that some users of CMV are intentionally not using version 3.10 of the API. I'm not sure of the reasoning for this but it is something that needs to be considered before supporting an api feature that just appeared in the newest version.

@kcarrier
Copy link
Author

@tmcgee - What triggers the identify is the layered in this case 13, this is the highest level zoom layerid in the rest endpoint.

var demographicsLayer = new ArcGISDynamicMapServiceLayer("http://engineer05.gomvo.org/arcgis/rest/services/SP/RoadRecords/MapServer");
              demographicsLayer.setInfoTemplates({
                 13: { infoTemplate: popupTemplate }
              });
              map.addLayer(demographicsLayer);

@tmcgee
Copy link
Member

tmcgee commented Aug 25, 2014

I recognize it is the highest zoom level but why would that trigger the identify? Seems somewhat arbitrary. Any documentation on this?

@kcarrier
Copy link
Author

@tmcgee - Good point not real sure. I can look around but @DavidSpriggs might be able to answer this better than I can, worth a call to Esri support though to see if they can explain it to a newbie like me, LOL.

@tmcgee
Copy link
Member

tmcgee commented Aug 25, 2014

good luck with ESRI support. LOL

@kcarrier
Copy link
Author

Well that was a quick call, looks like it happens on a click event of a graphic, basically was told same thing documentation says so we might have to wait on a better explanation from David in my opinion.

@tmcgee
Copy link
Member

tmcgee commented Aug 25, 2014

There is no graphic involved with a dynamic layer. There is one for a feature layer. So it sounds like the support person's explanation is bit out of date too. ;)

My point is more that the documentation is currently lacking. Even with an explanation from David (or my own exploration of the api's code on this), we may not want to build code to support undocumented behavior that may change in the future.

@DavidSpriggs
Copy link
Member

@kcarrier @tmcgee This behaviour is all baked into the map now to be more like AGO (you dont have to wire up identify, just define an pop up template and your good). There is a new prop on the map object to turn this on and off: showInfoWindowOnClick and corresponding method:
https://developers.arcgis.com/javascript/jsapi/map-amd.html#setinfowindowonclick

So we can use this new functionality in CMV by turning the feature off when using other tools.

@kcarrier
Copy link
Author

"Excellent Smithers!" (Bart Simpson reference), Well hopefully when there is time to work on it in CMV I can help test. We really need that feature as we have many map services with attachments enabled. Cannot replace our Flex stuff until I can get that working. I will wait patiently I promise, thanks for the help!

@tmcgee
Copy link
Member

tmcgee commented Aug 25, 2014

I saw that addition in the "What's New in Version 3.10" ArcGIS. It says `toggle the default behavior of showing the map's infoWindow when clicking a graphic.' which is incorrect since it appears to apply to dynamic and tiled layers as well.

Any idea why the identify is only triggered on the highest zoom level in kcarrier's example? I'm not sure we want to tap into this new feature if identify would only work at the highest zoom.

@tmcgee
Copy link
Member

tmcgee commented Aug 25, 2014

@karrier: you can't use a feature layer? that works already. You could add a feature layer (or layers) that only is visible at the highest zoom to mimic this behavior.

@tmcgee
Copy link
Member

tmcgee commented Aug 25, 2014

Oh I think I now see why it is only triggered on the highest zoom. The sublayer used in the example is only visible at that zoom level.

@kcarrier
Copy link
Author

@tmcgee - Feature Layers require SDE and we use file gdb as backend. I prefer to use map services over feature services for performance and file gdb over SDE for performance as well. We replicate the data in WMAS each night via script so there is no performance hit for projecting on the fly. I was told by Esri at UC 2014 that they are working on improving the performance of feature services but in my testing they are slower than map services plus I am not big on having web services hitting my database as we do not do any web editing it is all read only. More a preference, could it be done sure but there are some deeper issues like having to reconfig my entire backend process for pop-ups?

@tmcgee
Copy link
Member

tmcgee commented Aug 25, 2014

Are you talking about Feature Layers or Feature Services? You can have feature layers that point to a single sublayer in a Map Service. It does not have to be a Feature Service. In your Map Service, this is a feature layer: http://engineer05.gomvo.org/arcgis/rest/services/SP/RoadRecords/MapServer/13

Using a Feature Layer may not be your desired outcome. I am just pointing out that it is possible.

@pwild
Copy link

pwild commented Sep 24, 2014

Do I understand correctly that currently showAttachments will only work with feature layers and not dynamic layers in the CMV?
I have successfully included attachments to a single feature layer, but I lose the labeling as such. I would prefer not to include both feature and dynamic layers for the same object.
Hints?

@tmcgee
Copy link
Member

tmcgee commented Sep 24, 2014

That is correct. The ESRI Javascript API did not support showAttachments in the infoTemplate for dynamic layers until the recent version 3.1.0. We do plan to add this capability to CMV - it is balance to ensure we incorporate the newest capabilities while continuing to support older versions of the API that people are still using.

@goriliukasbuxton
Copy link

having trouble showing attachments added as feature layer in viewer.js. Is where a example with attachments configured?

@tmcgee
Copy link
Member

tmcgee commented Sep 30, 2014

The SF311 layer in the demo app uses showAttachments. For this particular layer, the infoTemplate is not defined in identify.js and so is created automatically by cmv. The code detects that attachments are available (hasAttachments: true for the layer) and builds the infoTemplate accordingly.

In your own infoTemplate defined in identify.js, you should just need to add showAttachments: true to enable the same functionality.

With either method, you'll need to confirm that your service has attachments. You can do this by examining the properties from the REST end point for the particular sub-layer of the map service/feature service.

@goriliukasbuxton
Copy link

Well, tried both methods, no Attachments are visible. Maybe because its a secure service?

@tmcgee
Copy link
Member

tmcgee commented Sep 30, 2014

Do you see the "Attachments:" heading at the bottom of the Info Window with the message "No Attachments Found"? If so, then your infoTemplate is configured correctly in CMV but the ESRI API is not finding the attachments. That's an API issue. You might want to try one of the ESRI sandbox examples with your service to see if it has similar results. I'm not aware of a problem with showAttachments with a secure service.

@DavidSpriggs
Copy link
Member

Try this one, it has a sandbox link:
https://developers.arcgis.com/javascript/jssamples/ed_attachments.html
or just add it on AGO and turn on attachemebts to test:
http://www.arcgis.com/home/webmap/viewer.html

@goriliukasbuxton
Copy link

The sandbox works with my feature layer. but it doesnt work with CMV
snippet:
{
type: "feature",
url: "[server]/rest/services/Panoramio/Trinidad/MapServer/0",
title: "Panoramio",
options: {
id: 'png1',
opacity: 1.0,
visible: true,
outFields: ["*"],
mode: 0
}

    },

Thank you guys.

@goriliukasbuxton
Copy link

Hello guys,
is this attachment problem is resolved in the 1.3.1 version of the viewer?

Thank you,

@tmcgee
Copy link
Member

tmcgee commented Nov 25, 2014

@goriliukasbuxton there has been no additional attention given to the additional showAttachments functionality added recently to the ESRI JS API. I will add this enhancement to the next development milestone for consideration.

@kcarrier
Copy link
Author

Here is another one, it is a point service

layerIds: [1,3,5,7,9,11,13]

http://engineer.gomvo.org/arcgis/rest/services/WMAS/MCEO_SurveyRecords/MapServer

Here is some code I was using

viewer.js:

operationalLayers: [{
            type: 'dynamic',
            url: 'http://engineer.gomvo.org/arcgis/rest/services/WMAS/MCEO_SurveyRecords/MapServer',
            title: 'Survey Records',
            options: {
                id: 'SurveyRecords',
                opacity: 1.0,
                visible: true,
                imageParameters: imageParameters
            },
            identifyLayerInfos: {
                layerIds: [1,3,5,7,9,11,13]
            }
  },

identify.js:

SurveyRecords: {
            1: {
                title: 'SURVEY_NUMBER',
                showAttachments: true,
                fieldInfos: [{
                    fieldName: 'SURVEY_NUMBER',
                    visible: true
                }]
            },
            3: {
                title: 'SURVEY_NUMBER',
                showAttachments: true,
                fieldInfos: [{
                    fieldName: 'SURVEY_NUMBER',
                    visible: true
                }]
            },
            5: {
                title: 'SURVEY_NUMBER',
                showAttachments: true,
                fieldInfos: [{
                    fieldName: 'SURVEY_NUMBER',
                    visible: true
                }]
            },
            7: {
                title: 'SURVEY_NUMBER',
                showAttachments: true,
                fieldInfos: [{
                    fieldName: 'SURVEY_NUMBER',
                    visible: true
                }]
            },
            9: {
                title: 'SURVEY_NUMBER',
                showAttachments: true,
                fieldInfos: [{
                    fieldName: 'SURVEY_NUMBER',
                    visible: true
                }]
            },
            11: {
                title: 'SURVEY_NUMBER',
                showAttachments: true,
                fieldInfos: [{
                    fieldName: 'SURVEY_NUMBER',
                    visible: true
                }]
            },
            13: {
                title: 'SURVEY_NUMBER',
                showAttachments: true,
                fieldInfos: [{
                    fieldName: 'SURVEY_NUMBER',
                    visible: true
                }]
            }
        },

@tmcgee
Copy link
Member

tmcgee commented Feb 27, 2015

@rkoelpin @kcarrier thank you. I guess if I was paying full attention last night, I would have noticed/remembered that kcarrier provided another example in the initial description of this issue. Now I have 3 examples to investigate. ;)

@kcarrier
Copy link
Author

@tmcgee - Thanks for looking into this, let me know if you need anything else.

@taran03
Copy link

taran03 commented Feb 27, 2015

Along these lines, I just noticed an issue in my CMV application with opening attachments on a secured service via the attachment link in the feature's ID pop up window. The attachment links display as intended in the pop up window, but when the user clicks on the attachment link the URL is calling for a redirect that requires the user to authenticate with our ArcGIS Server in order to see the attached image. Of course, the attachments work fine if the service is public. I'm already using proxy to auto authenticate user access to secure services, so I'm a little stumped as to why clicking on the attachment link leads to a login redirect page (the standard ArcGIS Server REST API Login page) instead of direct authentication from the functioning proxy. Any thoughts as to whether this is an ESRI thing or a CMV issue? Thanks.

image

image

@tmcgee
Copy link
Member

tmcgee commented Feb 27, 2015

@taran03 All of the logic for displaying the contents within the InfoWindow including the list of attachments and opening those attachments is handled by the ESRI JS API. Sorry if that comes across like I'm passing the buck. ;)

@taran03
Copy link

taran03 commented Feb 27, 2015

Ok, that is what I suspected. Thanks for confirming this.

@kcarrier
Copy link
Author

kcarrier commented Mar 4, 2015

@tmcgee - I know you have other things in your life to do but I was just curious what the initial findings were from the examples we were able to provide.

@tmcgee
Copy link
Member

tmcgee commented Mar 5, 2015

@kcarrier Sorry, I have not had the opportunity yet.

@kcarrier
Copy link
Author

@tmcgee - Hope you had a good time at DevSummit, just checking in.

@tmcgee
Copy link
Member

tmcgee commented Mar 26, 2015

@kcarrier this is still on my "when I get around to it" list.

@tmcgee
Copy link
Member

tmcgee commented Apr 18, 2015

@kcarrier: I finally spent some time this afternoon to look into this. This default map functionality behind the mapclick is not well documented in the API docs beyond what @DavidSpriggs mentioned about the setInfoWindowOnClick method to turn it on/off. In essence they treat each sublayer in a dynamic layer as if it were a feature layer - that's is why the showAttachments behaves similar to that of a feature layer. They then use multiple QueryTasks per layer (one per sub layer) to get the identify results instead of a single IdentifyTask per layer as we do in CMV.

You can use the built-in functionality within the map in CMV. You will need to not include the identify widget in your app and you will need to define your infoTemplates directly within each operationalLayer like this:

{
        type: 'dynamic',
        url: 'http://engineer.gomvo.org/arcgis/rest/services/WMAS/MCEO_SurveyRecords/MapServer',
        title: 'Survey Records',
        options: {
            id: 'SurveyRecords',
            opacity: 1.0,
            visible: true,
            imageParameters: imageParameters,
            infoTemplates: {
                1: {
                    infoTemplate: new PopupTemplate({
                        title: 'SURVEY_NUMBER',
                        showAttachments: true,
                        fieldInfos: [{
                            fieldName: 'SURVEY_NUMBER',
                            visible: true
                        }]
                    })
                }
            }
        }
}

I have not tested whether this plays nice with other cmv widgets that interact with the map so there may be a can of worms there.

I'm not sure if it a good idea or not to do away with the current Identify widget completely within CMV and rely on this undocumented functionality. That would require more discussion. I'm not a fan of their approach since using QueryTask as ESRI does instead of IdentifyTask is certainly less efficient for the server and the client.

Now that I have a better understanding of what they are doing and why it behaves the way it does, I have a few thoughts to explore how we might incorporate similar showAttachments functionality for dynamic layers within the cmv identify widget.

@DavidSpriggs DavidSpriggs removed this from the v1.3.3 milestone Apr 21, 2015
@kcarrier
Copy link
Author

@tmcgee - I just tested the code above and it does not work as expected. Still no attachments coming through in the Popup Window, just the Survey Number comes through in the title and in the field section.

@tmcgee
Copy link
Member

tmcgee commented Apr 23, 2015

Hmm. I used the exact layer config that I posted above and the attachments were there in the InfoWindow. Did you disable the cmv Identify widget? That's an integral step to getting this to work..

@kcarrier
Copy link
Author

@tmcgee - Disabling the identify fixed it, sorry glossed over that step. So rather than build the identifies in the identify.js file, I would just build them within viewer.js correct? Thanks for the prompt reply very much appreciated!

@kcarrier
Copy link
Author

@tmcgee - Thanks again for all the help!

@igover007
Copy link

@DavidSpriggs , @tmcgee . Hi all, love the work going on here. Just wondering, with regard to the showInfoWindowOnClick functionality, where abouts in CMV do I setInfoWindowOnClick(true); ?
Thanks again for working on this.

@tmcgee
Copy link
Member

tmcgee commented May 6, 2015

@igover007 There isn't anything to set for this functionality. The default value is true.

@kcarrier kcarrier reopened this Aug 19, 2015
@kcarrier
Copy link
Author

@tmcgee - It appears I might not be able to use the description method in the viewer.js file, it is like it does not recognize anything except the first field value, all other field values come back blank. The attachments still work as you explained earlier but now the field values are not coming through as they were in the identify.js file. When I use fieldInfos[{}] as specified in the Esri JS API documentation the values come through, any thoughts. My code example can be seen below, the map service is publicly accessible.

https://gist.github.com/kcarrier/d28cec24ebc9a2f4f708

@tmcgee
Copy link
Member

tmcgee commented Aug 19, 2015

@kcarrier the description property in your example looks correct (when used in identify.js). This infoTemplates functionality for dynamic layers is relatively new and not well documented so it could be that the description parameter is not (yet) supported by the API for a dynamic layer's infoTemplates array.

@kcarrier
Copy link
Author

@tmcgee - I think I see where I screwed up I did not close the table
but I just tried again after closing the table correctly in the code and it is still not working as expected only the first field is populated all remaining fields still come back as blank.

@kcarrier
Copy link
Author

@tmcgee - I am trying to allow for the attachments to be visible and this is working the issue I am running into now is that I have some fields which have hyperlinks and i am not sure how to set the code up to support both hyperlinks and showAttachments. The question I guess I need to try and figure out is there any way of having a hyperlink value inside of fieldInfos.

description works but only for the first field and I am not sure if it is possible to get a hyperlink inside of fieldInfos any thoughts?

{
            type: 'dynamic',
            url: 'http://maps6.cityoftrenton.com/arcgis/rest/services/Water/WaterLayers/MapServer',
            title: 'Water Assets',
            noLegend: true,
            collapsed: true,
            options: {
                id: 'waterassets',
                opacity: 1,
                visible: true,
                imageParameters: imageParameters,
                infoTemplates: {
                    1: {
                        infoTemplate: new PopupTemplate({
                            title: 'Water Curb Stop Valve',
                            showAttachments: true,
                            description:[
                            '<table class="attrTable">',
                            '<tr valign="top">',
                            '<td class="attrName">Control Station Data Sheet :</td>',
                            '<td class="attrValue"><a href="{HYPERLINK}" target="_blank">Click Here</a></td>',
                            '</tr>',
                            '</table>'
                            ].join('')
                            fieldInfos: [
                            { fieldName: 'MAPREF', label: 'MAPREF : ', visible: true },
                            { fieldName: 'FACILITYID', label: 'Facility ID : ', visible: true },
                            { fieldName: 'LOCDESC', label: 'Address : ', visible: true },
                            { fieldName: 'ROTATION', label: 'Rotation : ', visible: true },
                            { fieldName: 'DIAMETER', label: 'Diameter : ', visible: true },
                            { fieldName: 'VALVETYPE', label: 'Valve Type : ', visible: true },
                            { fieldName: 'NORMALLYOPEN', label: 'Normally Open : ', visible: true },
                            { fieldName: 'TURNSTOCLOSE', label: 'Turns To Close : ', visible: true },
                            { fieldName: 'OPERABLE', label: 'Operable : ', visible: true },
                            { fieldName: 'CURROPEN', label: 'Currently Open : ', visible: true },
                            { fieldName: 'ACTIVEFLAG', label: 'Active : ', visible: true },
                            { fieldName: 'OWNEDBY', label: 'Owned By : ', visible: true },
                            { fieldName: 'MAINTBY', label: 'Managed By : ', visible: true },
                            { fieldName: 'Install_Year', label: 'Install Year : ', visible: true }
                            ]
                        })
                    }
                },
                layerControlLayerInfos: {
                    sublayers: false
                }
            }
        }

@kcarrier
Copy link
Author

@tmcgee - I think I figured out how to get description to work in conjunction with fieldInfos. I was trying some different methods and move fieldInfos above description and with both of them under the PopupTemplate it is now working and I can have hyperlinks and attachments, in case anyone ever runs across this, here is how I got it to work. It almost seems like in order for description to work inside of viewer.js as shown below you have to have fieldInfos setup so the api knows how to get the field and field value from REST or something along those lines.

{
            type: 'dynamic',
            url: 'http://maps6.cityoftrenton.com/arcgis/rest/services/Water/WaterLayers/MapServer',
            title: 'Water Assets',
            noLegend: true,
            collapsed: true,
            options: {
                id: 'waterassets',
                opacity: 1,
                visible: true,
                imageParameters: imageParameters,
                infoTemplates: {
                    1: {
                        infoTemplate: new PopupTemplate({
                            title: 'Water Curb Stop Valve',
                            showAttachments: true,
                            fieldInfos: [
                            { fieldName: 'FACILITYID', label: 'Facility ID : ', visible: true },
                            { fieldName: 'MAPREF', label: 'MAPREF : ', visible: true },
                            { fieldName: 'LOCDESC', label: 'Address : ', visible: true },
                            { fieldName: 'ROTATION', label: 'Rotation : ', visible: true },
                            { fieldName: 'DIAMETER', label: 'Diameter : ', visible: true },
                            { fieldName: 'VALVETYPE', label: 'Valve Type : ', visible: true },
                            { fieldName: 'NORMALLYOPEN', label: 'Normally Open : ', visible: true },
                            { fieldName: 'TURNSTOCLOSE', label: 'Turns To Close : ', visible: true },
                            { fieldName: 'OPERABLE', label: 'Operable : ', visible: true },
                            { fieldName: 'CURROPEN', label: 'Currently Open : ', visible: true },
                            { fieldName: 'ACTIVEFLAG', label: 'Active : ', visible: true },
                            { fieldName: 'OWNEDBY', label: 'Owned By : ', visible: true },
                            { fieldName: 'MAINTBY', label: 'Managed By : ', visible: true },
                            { fieldName: 'Install_Year', label: 'Install Year : ', visible: true }
                            ],
                            description: [
                            '<table class="attrTable">',
                            '<tr valign="top">',
                            '<td class="attrName">Diameter :</td>',
                            '<td class="attrValue"><a href="{DIAMETER}" target="_blank">{DIAMETER}</a></td>',
                            '</tr>',
                            '<tr valign="top">',
                            '<td class="attrName">MAPREF :</td>',
                            '<td class="attrValue"><a href="{MAPREF}" target="_blank">{MAPREF}</a></td>',
                            '</tr>',
                            '<tr valign="top">',
                            '<td class="attrName">VALVETYPE :</td>',
                            '<td class="attrValue"><a href="{VALVETYPE}" target="_blank">{VALVETYPE}</a></td>',
                            '</tr>',
                            '</table>'
                            ].join('')
                        })
                    }
                },
                layerControlLayerInfos: {
                    sublayers: false
                }
            }
        }

@rutzmosh
Copy link

I found this thread looking for answer, my popups were not showing attachments in for dynamic layers, I needed for only a few items...add similar lines starting around line 288 of the identify.js file.
Basically you can hijack the identify use the default htmlPopup template for the layers of interest...default works fine but you can get really fancy with the html popup prior to publishing your map service.

                    if (infoTemplate) {
                        //custom handle layers with attachments work around for now...
                        if (infoTemplate.info.title == 'My layer with attachments'){
                             infoTemplate.setTitle("<b>My layer with attachmentss</b>");
                             infoTemplate.setContent("<iframe src='https://your_url.com/arcgis/rest/services/Utilites/MapServer/0/${OBJECTID}/htmlPopup?f=html' frameborder='0' width='275px' height='800px' style='width: 275px; height: 800px; display: block; padding: 0px; margin: 0px;'></iframe>");
                        }                           
                        result.feature.setInfoTemplate(infoTemplate);
                    } else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants