cmv / cmv-app

CMV - The Configurable Map Viewer - A community supported open source mapping framework built with the Esri JavaScript API and the Dojo Toolkit
https://demo.cmv.io/
MIT License
325 stars 278 forks source link

showAttachments not honored in Identify.js against MapService #177

Closed kcarrier closed 7 years ago

kcarrier commented 10 years ago

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.

kcarrier commented 9 years ago

@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 commented 9 years ago

@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 commented 9 years ago

@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 commented 8 years ago

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