steinj14

how to customize popup functionality of webmap created via code?

Discussion created by steinj14 on Oct 29, 2013
Latest reply on Nov 21, 2013 by steinj14
I have downloaded the basic template viewer and have created the webmap via code.  See below for snippet of how I define the layers.
           //Existing Land Use (popup)
           { "url": "http://gis.tpcmaps.org/ArcGIS/rest/services/LandUse/Existing_Land_Use/MapServer/0",
             "visibility": true,
             "opacity": 0,
             "mode": 2,  //Selection-only
             "layerDefinition": {
              "minScale": 100000,
              "maxScale": 0,
             },
             "title": "popup Existing Land Use",
             "id": "popelu",
             "popupInfo": {
          "title": "Existing Land Use",        
          "fieldInfos": [
            {'fieldName': "JURISDICTION","label": "Jurisdiction","visible": true,},
            {"fieldName": "ELUSHADE","label": "Existing LU","visible": true,},           
            {"fieldName": "ELU2_DESC","label": "Description","visible": true,}           
          ],
             "description": null
             }
           }, 
           //Existing Land Use (display tiled service)
           { "url": "http://gis.tpcmaps.org/ArcGIS/rest/services/LandUse/Existing_Land_Use/MapServer",
             "visibility": false,
             "opacity": 0.75,
             "title": "Existing Land Use",
             "id": "elu",
             "description": null
           }, 
           //TT Zoning (popup)
           { "url": "http://gis.tpcmaps.org/ArcGIS/rest/services/Rezoning/Zoning/MapServer/0",
             "visibility": true,
             "opacity": 0,
             "mode": 2, //Selection-only                        
             "title": "popup TT Zoning",
             "id": "popttzon",
             "popupInfo": {
          "title": "TT Zoning",
          "fieldInfos": [
            {"fieldName": "ZONING","label": "Zoning","visible": true,},                              
          ],       
             "description": null
             }
           },             
           //TT Zoning (display dynamic service, set visibleLayers)                                  
           { "url": "http://gis.tpcmaps.org/ArcGIS/rest/services/Rezoning/Zoning/MapServer",
             "visibility": false,
             "opacity": 0.75,
             "visibleLayers": [0], //set layer to Zoning
             "title": "TT Zoning",
             "id": "ttzon",
             "description": null
           },  


As you can see, I'm having to load the map service for display purposes and the individual layer for the popup functionality.

The default behavior of clicking on the map opens the popup infowindow. The issue is that there are around 20 individual layers in the webmap so the popup returns a lot of results (which is slow and/or more than the user is interested in).

Instead, when the user clicks on the map, I'd like to query the visible layers (map services), create a list of the corresponding popup layers, and use that list in the popup functionality.  But where in the code would I set the layer list that the popup uses? Can that list be "refreshed" every time the user clicks on the map?

Am I over-complicating things? Is there an easier way to accomplish what I'm trying to do?

Thanks

Outcomes