0

Is there a way to pass an attribute to the cmv through a URL?

Here's an example from my current site of what I want to do.. https://ags2.scgov.net/SCPAparcels/?esearch=2027070041&slayer=0&exprnum=0&showdatagrid=false

I need to be able to pass a parcel ID number from our property website through a URL (got that part covered), so that the map will open at the selected parcel.

1

You can do nearly the same thing as you do in the Flex app in your link using the Attributes Table widget from my CMV widgets repo.

Below is a complete example that will select Sarasota County from an ESRI sample Census layer. The first few lines retrieve the FIPS code from the query string. The FIPS code is then used by the where clause in the queryOptions for the Attributes Table.

define([
    'dojo/io-query'
], function (ioQuery) {

    var uri = window.location.href;
    var qs = uri.substring(uri.indexOf('?') + 1, uri.length);
    var qsObj = ioQuery.queryToObject(qs);
    var fips = qsObj.fips || '';

    return {
        isDebug: false,

        mapOptions: {
            basemap: 'streets',
            center: [-96.59179687497497, 39.09596293629694],
            zoom: 5,
            sliderStyle: 'small'
        },

        panes: {
            left: {
                collapsible: false,
                style: 'display:none'
            },
            bottom: {
                id: 'sidebarBottom',
                placeAt: 'outer',
                splitter: true,
                collapsible: true,
                region: 'bottom',
                style: 'height:200px;',
                content: '<div id="attributesContainer"></div>'
            }
        },

        operationalLayers: [
        ],

        widgets: {
            growler: {
                include: true,
                id: 'growler',
                type: 'domNode',
                path: 'gis/dijit/Growler',
                srcNodeRef: 'growlerDijit',
                options: {}
            },
            attributesTable: {
                include: true,
                id: 'attributesContainer',
                type: 'domNode',
                srcNodeRef: 'attributesContainer',
                path: 'widgets/AttributesTable',
                options: {
                    map: true,
                    mapClickMode: true,

                    // use a tab container for multiple tables or
                    // show only a single table
                    useTabs: false,

                    // used to open the sidebar after a query has completed
                    sidebarID: 'sidebarBottom',

                    tables: [
                        {
                            title: 'Census',
                            topicID: 'censusQuery',
                            queryOptions: {
                                queryParameters: {
                                    url: 'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/4',
                                    where: 'FIPS = \'' + fips + '\''
                                },
                                idProperty: 'ObjectID'
                            },
                            toolbarOptions: {
                                show: false
                            }
                        }
                    ]
                }
            }
        }
    };
});
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.