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

changing default info window #212

Closed
MesquiteGIS opened this issue Sep 16, 2014 · 14 comments
Closed

changing default info window #212

MesquiteGIS opened this issue Sep 16, 2014 · 14 comments

Comments

@MesquiteGIS
Copy link

Is it possible to change the title, field labels, and which fields are displayed in the default popup window? Cant seem to get anything to work.

Thanks!

@friendde
Copy link
Contributor

For field labels use the field names alias in your database.

@tmcgee
Copy link
Member

tmcgee commented Sep 17, 2014

As @friendde mentioned, the field aliases are returned from the IdentifyTask.

There are examples within the config/identify file which demonstrate the basics of using the title and an array of fieldInfos to list. If you do not provide the configuration within the identify file I mentioned, they will be defaulted from the fields in the layer. That is probably what you are seeing now.

@MesquiteGIS
Copy link
Author

Thanks for both of your replies. I'm having trouble with using identify on one layer because it is a dynamic service. Just doesnt get recognized through the identify widget. I've since read tmcgee post concerning this issue, and I'll try again as a feature service.

Thanks!

@DavidSpriggs
Copy link
Member

Dynamic LAyers work fine. Are you setting an id on the layer then have a corresponding key in the identify config? Post code.

@friendde
Copy link
Contributor

As David suggested verify your config\identify.js file. Here is my example, layerid comes from your rest end point.

        www: {
            2: {
                title: 'Hydrant w/ Fireflow',
                fieldInfos: [{
                    fieldName: 'FacilityID',
                    label: 'number',
                    visible: true
                }, {
                    fieldName: 'Hydrant ID',
                    visible: true
                }, {
                    fieldName: 'Horizontal Data Source',
                    visible: true
                }]
            },
            3: {
                title: 'Hydrant',
                fieldInfos: [{
                    fieldName: 'FacilityID',
                    label: 'Number',
                    visible: true
                }, {
                    fieldName: 'INSTALLDATE',
                    visible: true
                }, {
                    fieldName: 'Hydrant ID',
                    visible: true
                }, {
                    fieldName: 'OWNER',
                    visible: true
                }, {
                    fieldName: 'HORIZONTAL DATA SOURCE',
                    visible: true
                }, {
                    fieldName: 'HYDRANT ID SOURCE',
                    visible: true
                }, {
                    fieldName: 'FIRE FLOW',
                    visible: true
                }]
            },

@rogers259
Copy link

Also here's a bit of an example on customizing things a bit

identifies: {
        landBase: {
            4: {
                title: '{COUNTY} COUNTY PARCEL:<br />' + '{PIN}',
                description: "<b>Owner</b>: {OWNER1}<br />" +
                    "<b>Acres</b>: {CALC_ACRES}<br />" +
                    "<a href='{AUD_LINK}' target='_blank'>Search Auditor Website</a>"
            }
        },
        Wells: {
            1: {
                title: 'Active Well: {Well_API_Wellno}',
                description: "<b>Well Status</b>: {Well_Well_Status_Description}<br />" +
                    "<b>Well Name</b>: {WELL_Well_Name}<br />" +
                    "<b>Well Number</b>: {Well_WELL_NO}<br />" +
                    "<b>Producing Formation</b>: {FirstProdFormation}<br />" +
                    "<a href='https://gis._.gov/Website/DOG/WellSummaryCard.asp?api={Well_API_Wellno}' target='_blank'>Well Summary Report Link</a>" +
                    "<hr />" +
                    "<B><U><Center>Well Company Information</U></B><br />" +
                    "{Well_CompanyName}<br />" +
                    "{Well_CompanyADDR1}<br />" +
                    "{Well_CompanyCITY} {Well_CompanyZIP1}<br />" +
                    "Phone #: {Well_CompanyPHONE}</Center>"
            },

Here's what the popup looks like for the Active Well

image

Hope that helps you a bit.

@tmcgee
Copy link
Member

tmcgee commented Sep 17, 2014

thanks @rogers259 Nice example.

To add to the discussion, when building the description, I like to use an html table so that the field names and values line up vertically. It makes the configuration a little more verbose but easier for end users to scan the info presented. If you use the proper classes, the bolding, alignment and striping of rows is handled.

Here's a quick little example:

2: {
    title: 'Sign Programs',
    description: [
        '<table class="attrTable">',
            '<tr valign="top">',
                '<td class="attrName">Program:</td>',
                '<td class="attrValue">{SPROGRAMNA}</td>',
            '</tr>',
            '<tr valign="top">',
                '<td class="attrName">Document:</td>',
                '<td class="attrValue"><a href="http://server/SignPrograms/documents/{SPDOCUMENT}.pdf" target="_blank">{SPDOCUMENT}</a></td>',
            '</tr>',
            '<tr valign="top">',
                '<td class="attrName">Image:</td>',
                '<td class="attrValue"><a href="http:/server/SignPrograms/images/{IMAGE}.pdf" target="_blank">{IMAGE}</a></td>',
            '</tr>',
            '<tr valign="top">',
                '<td class="attrName">Historic District:</td>',
                '<td class="attrValue">{HCDZONES}</td>',
            '</tr>',
        '</table>'
    ].join('')
},

image

As an aside, if you do not create a configuration for your layer(s) in the config/identify file, cmv will automatically use similar tabular formatting as I wrote above to present your attributes. The styling might be a little different. Hope this helps others.

@MesquiteGIS
Copy link
Author

These suggestions and tips helped a lot. Thanks! I found the layer I was trying to identify wouldn't do so because it was set to not display until a certain extent. Once I opened this up to always display, it was able to identify.

Thanks again!

@MesquiteGIS
Copy link
Author

On a side question to this.Is there a way to disable the default info window from coming up all together. I'm using an address point layer which I only want to appear once zoomed in to a certain extent. To get to identify function to work on this layer, I had to add two separate map services. One where the address point is open to all extents, but with no visible symbology, and another with the symbology and display settings how I want them. I would like to disable the default info window for the later service.

Thanks

@MesquiteGIS
Copy link
Author

Figured out a work around for my last comment. The default pop up window can be disabled by commenting out a section of code in the js/gis/dijit.identify.js file. Approximately lines 246-295.

thanks

@tmcgee
Copy link
Member

tmcgee commented Sep 22, 2014

@MesquiteGIS, if add the following to your your operational layer, it will exclude that one layer from the Identify:

identifyLayerInfos: {
    exclude: true
}

that's the preferred method leaving the cmv core widget untouched.

We just pushed out release 1.30 minutes ago which adds some additional enhancements to the Identify widget. This includes an option createDefaultInfoTemplates: false to prevent the automatic creation of infoTemplates. This means your app would only identify layers that you have explicitly configured in config/identify. That might be useful for you in this case.

@tmcgee tmcgee mentioned this issue Sep 24, 2014
@pwild
Copy link

pwild commented Sep 24, 2014

Would both the above suggestions for disallowing popups to a specific layer be dependent on the latest version of CWV?
If not, can someone provide an example of the correct placement of the code?

@tmcgee
Copy link
Member

tmcgee commented Sep 24, 2014

I know that the first suggestion was available at release 1.2.0, perhaps before that. There is an example of using identifyLayerInfos in the demo config/viewer file: https://github.com/cmv/cmv-app/blob/master/viewer/js/config/viewer.js#L102

@cmccullough2
Copy link

Can you have a pie chart within a table row or between an hr tag?

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

7 participants