0

I am trying to pass a url query to query and zoom to a feature and I'm having a hard time doing so. I've followed a few threads on this with no luck:

https://github.com/JoelHearne/CMV_InitZoomer

Pass an attribute to the find widget using a URL string

https://github.com/tmcgee/cmv-widgets/blob/master/config/queryStringSearch.js

A few of my code snippets:

Here is an example URL query string where I'd like to search a specific field within a layer: https://mapservice.nmstatelands.org/LandStatus/?config=queryStringSearch&id=va20540002

The following code results in a 404 from esri when loading the map:

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 uniquekey = qsObj.UNIQUEKEY || '';

    return {
        isDebug: false,

        mapOptions: {
            basemap: 'topo',
            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: 'dynamic',
                            topicID: 'Leases',
                            queryOptions: {
                                queryParameters: {
                                    url: 'https://mapservice.nmstatelands.org/arcgis/rest/services/Public/SLO_Active_Leases_t/MapServer/2',
                                    where: 'UNIQUEKEY = \'' + uniquekey + '\''
                                },
                                idProperty: 'ObjectID'
                            },
                            toolbarOptions: {
                                show: false
                            }
                        }
                    ]
                }
            }
        }
    };
});

This code seems to have no effect when placed in the widgets section:

 queryString: {
                include: true,
                id: 'UNIQUEKEY',
                type: 'invisible',
                path: 'dijit/_WidgetBase',
                options: {
                    startup: function () {
                        var uri = window.location.href;
                        var qs = uri.substring(uri.indexOf('?') + 1, uri.length);
                        var qsObj = ioQuery.queryToObject(qs);
                        var id = qsObj.ID;
                        if (id) {
                            window.setTimeout(function () {
                                topic.publish('searchResults/search', {
                                    layerIndex: 0,
                                    searchTerm: id
                                })
                            }, 2000);
                        }
                    }
                }
            },

I've also tried to pass the query through the find.js module with no luck.

Your Answer

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

Browse other questions tagged or ask your own question.