How to build URL query parameters in Web AppBuilder for layer inside a group

311
6
01-07-2020 08:49 AM
JoseSanchez
Occasional Contributor III

Hello everyone,

I want to query a layer that is inside a group in a Web Map. I tried to follow the samples to query the first layer in the group, in ths case id="0".   This s the link I am following to build the URL query: -https://doc.arcgis.com/en/web-appbuilder/manage-apps/app-url-parameters.htm-  but because the layer is in a group I am not able to make the query work.

Samples I have done:

 https://myarcgisonline.com/Projects/index.html?webmap=.......&query=MyGroup_4686, PROJECTID='22209'

 or

 https://myarcgisonline.com/Projects/index.html?webmap=.......&query=MyWasdDeveloperAgreements_4686_0https://myarcgisonline.com/Projects/index.html?webmap=.......&query=0https://myarcgisonline.com/Projects/index.html?webmap=.......&query=0https://myarcgisonline.com/Projects/index.html?webmap=.......&query=0, PROJECTID='22209'

I do not know how to correctly build an url string with query parameters when the layer is in a group.

In this case the layer has  "id": 0,  

This is how the config,json file has the layers listed.

Config file.

{
            "id": "MyGroup_4686",     ********************************************  THIS IS THE GROUP
            "layerType": "ArcGISMapServiceLayer",
            "url": "https://................../MapServe",
            "visibility": true,
            "visibleLayers": [
                0,
                1
            ],
            "opacity": 1,
            "title": "Projects",
            "layers": [
                {
                    "id": 0,                   ********************************************* THIS IS THE LAYER I WANT TO SEARCH

                ......
                },
                {
                    "id": 1,
   "popupInfo": {
                        "title": "Future  Projects",
                   

0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Jose,

   I find the easiest way to find the exact layer id is to use the LayerList widget and right click on the sublayer of interest and choose inspect to bring up the element in the developer tools. Then in the class attribute you will see the exact id of the layer (i.e. "ParcelViewerWM_1607_141"). The whole class attribute will be "layer-title-div-ParcelViewerWM_1607_141 div-content jimu-float-leading" so you just extract the "layer-title-div-" portion and everything after the space.

0 Kudos
JoseSanchez
Occasional Contributor III

Thanks, I found the name of the layer:  MyGroup_4686_0

https://.../Projects/index.html?query=MyGroup_4686_0,PROJECTID='22209'

It does not work.

We are using Web AppBuilder 2.0, is there any need to update any of the config files

https://...../iWASDProjects/index.html?query=MyWasdDeveloperAgreements_4686_0,AGMID='22209'

thanks

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Jose,

   I that 2.01 had an issue with the query layer being in a different WKID than the map. Your layers data is WKID 102658 and the map is 102100 and there is no method in the old 2.0 WAB to set the query outspatialreference to the maps spatial reference.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

In the 2.14 version of WAB the jimu.js\MapURLParamsHandler.js > SelectFeatures method has this (notice line 5, which your code does not have in version 2.01):

  function selectFeatures(map, layer, queryArray){
    var query = new Query();
    var prefix = '';

    query.outSpatialReference = map.spatialReference;
0 Kudos
JoseSanchez
Occasional Contributor III

Thank you!!  We are going  to test these changes in our development version.

0 Kudos
JoseSanchez
Occasional Contributor III

Hello everyone,

Finally I was able to do it, but using the extent:

http://<your portal url>/apps/webappviewer/index.html?extent=-13079253.954115,3959110.38566837,-12918205.318785,4086639.70193162,102113

 

Dim URL As String = System.Configuration.ConfigurationManager.AppSettings.Item("MyGISViewerPortalURL")
Dim myWKID As String = System.Configuration.ConfigurationManager.AppSettings.Item("WKID")
URL = URL & strxmin & "," & strymin & "," & strxmax & "," & strymax & "," & myWKID

0 Kudos