Popup Window

1072
10
07-30-2013 06:48 AM
NicholasKnabe
New Contributor
I have a popup window when you click on my features. I have 15 different layers but only one is visible from the start. I cannot for the life of me figure out how to identify just the layers that are visible. I have gone through all the tutorials and read through all the forums as well. I had it working before I got my rest services to say that the features are visible by default.

Also I cannot figure out how to incorporate a hyperlink (youtube link) attribute into my popup window so it is clickable

Thanks
0 Kudos
10 Replies
KenBuja
MVP Esteemed Contributor
What are the parameters you're setting for the IdentifyTask? This should return just the visible layers

        identifyTask = new esri.tasks.IdentifyTask(yourUrl);
        identifyParams = new esri.tasks.IdentifyParameters();
        identifyParams.tolerance = 3;
        identifyParams.returnGeometry = true;
        identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
        identifyParams.width = map.width;
        identifyParams.height = map.height;
0 Kudos
NicholasKnabe
New Contributor
  function mapReady(map) {
          dojo.connect(map, "onClick", executeIdentifyTask);
          //create identify tasks and setup parameters 
          identifyTask = new esri.tasks.IdentifyTask("http://maps101.gis.halff.com/ladon/rest/services/Lubbock/LubbockCCTVAssets/MapServer/");
          identifyParams = new esri.tasks.IdentifyParameters();
          identifyParams.tolerance = 3;
          identifyParams.returnGeometry = true;
          identifyParams.layerIds = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17];
          identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
          identifyParams.width = map.width;
          identifyParams.height = map.height;

      }
0 Kudos
KenBuja
MVP Esteemed Contributor
  function mapReady(map) {
          dojo.connect(map, "onClick", executeIdentifyTask);
          //create identify tasks and setup parameters 
          identifyTask = new esri.tasks.IdentifyTask("http://maps101.gis.halff.com/ladon/rest/services/Lubbock/LubbockCCTVAssets/MapServer/");
          identifyParams = new esri.tasks.IdentifyParameters();
          identifyParams.tolerance = 3;
          identifyParams.returnGeometry = true;
          identifyParams.layerIds = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17];
          identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
          identifyParams.width = map.width;
          identifyParams.height = map.height;

      }


You can set the layerIds property to the visible layers (setting this property any time you change the visibility of one of the layers) or you can leave that property off and set the layerOption property to esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE
0 Kudos
NicholasKnabe
New Contributor
I've done both and it still ID's every layer. Thanks for the try. Been stumped for a month now
0 Kudos
KenBuja
MVP Esteemed Contributor
Can you post your full code or make a Fiddle that shows the problem?
0 Kudos
NicholasKnabe
New Contributor
They are secured services and I do not know if my IT would want me to share the login credentials. It just doesn't make sense I have it changed to VISIBLE and it still ID's every layer that is within the tolerance no matter if it is turned on or off.

Thanks for trying
0 Kudos
NicholasKnabe
New Contributor
          var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer")
          map.addLayer(basemap);



          var lubbock = new esri.layers.ArcGISDynamicMapServiceLayer("http://maps101.gis.halff.com/ladon/rest/services/Lubbock/LubbockCCTVAssets/MapServer", {
              id: 'lubbock',
              opacity: 0.8
          });

          map.addLayers([lubbock]);



          dojo.connect(map, 'onLayersAddResult', function (results) {
              var toc = new agsjs.dijit.TOC({
                  map: map,
                  layerInfos: [{
                      layer: lubbock,
                      title: "Lubbock CCTV Assets"
                  }, ]
              }, 'tocDiv');
              toc.startup();

              lubbock.setVisibleLayers([9]);

              

          });
          function mapReady(map) {
              dojo.connect(map, "onClick", executeIdentifyTask);
              //create identify tasks and setup parameters 
              identifyTask = new esri.tasks.IdentifyTask("http://maps101.gis.halff.com/ladon/rest/services/Lubbock/LubbockCCTVAssets/MapServer/");
              identifyParams = new esri.tasks.IdentifyParameters();
              identifyParams.tolerance = 3;
              identifyParams.returnGeometry = true;
              
              identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
              identifyParams.width = map.width;
              identifyParams.height = map.height;

          }

          function executeIdentifyTask(evt) {
              identifyParams.geometry = evt.mapPoint;
              identifyParams.mapExtent = map.extent;
             






              var deferred = identifyTask.execute(identifyParams);

              deferred.addCallback(function (response) {
                  // response is an array of identify result objects    
                  // Let's return an array of features.
                  return dojo.map(response, function (result) {
                      var feature = result.feature;
                      feature.attributes.layerName = result.layerName;

                      if (result.layerName === 'Survey Points') {
                          console.log(feature.attributes.OBJECTID);
                          var template = new esri.InfoTemplate("Survey Points", "<br/> Unique ID: ${UNIQUE_ID}<br/> X Coord: ${X_COORD}<br/> Y Coord: ${Y_COORD}<br/> Z Coord: ${Z_COORD}<br/> Type:${Type}<br/> Status: ${Status}<br/> Data Source: ${DATA_SOURCE}<br/> Shape: ${SHAPE}<br/> Survey Date: ${SURVEY_DATE}<br/>Alternate Name: ${ALT_NAME}");


                          feature.setInfoTemplate(template);

                      }
                      else if (result.layerName === 'CCTV Observations') {
                          var template = new esri.InfoTemplate("CCTV Observations", "<br/> CCTV Route: ${CCTV_ROUTE}<br/> CCTV Distance: ${CCTV_DISTANCE}<br/> CCTV Code: ${CCTV_CODE}<br/> CCTV Value Percent: ${CCTV_VALUE_PERCENT}<br/> CCTV Clock From: ${CCTV_CLOCK_FROM}<br/> CCTV Clock To: ${CCTV_CLOCK_TO}<br/> CCTV Grade: ${CCTV_GRADE} <br/>CCTV Continuous: ${CCTV_CONTINUOUS}<br/> CCTV Observation Type:${CCTV_OBS_TYPE}<br/> CCTV Observation:${CCTV_OBSERVATION}<br/> CCTV Remark:${CCTV_REMARK} <br/>Shape:${SHAPE}<br/> CCTV Attachment:${CCTV_Attach}");
                          feature.setInfoTemplate(template);
                      }

                      else if (result.layerName === 'Manholes') {
                          var template = new esri.InfoTemplate("Manholes", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Inlets') {
                          var template = new esri.InfoTemplate("Inlets", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Infalls') {
                          var template = new esri.InfoTemplate("Infalls", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Outfalls') {
                          var template = new esri.InfoTemplate("Outfalls", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Channel Features') {
                          var template = new esri.InfoTemplate("Channel Features", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Pipe Features') {
                          var template = new esri.InfoTemplate("Pipe Features", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Playa Centroids') {
                          var template = new esri.InfoTemplate("Playa Centroids", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Pipes') {
                          var template = new esri.InfoTemplate("Pipes", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Flumes') {
                          var template = new esri.InfoTemplate("Flumes", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Dams') {
                          var template = new esri.InfoTemplate("Dams", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Channels') {
                          var template = new esri.InfoTemplate("Channels", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'CCTV Routes') {
                          var template = new esri.InfoTemplate("CCTV Routes", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Virtual Links') {
                          var template = new esri.InfoTemplate("Virtual Links", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Stormwater Systems') {
                          var template = new esri.InfoTemplate("Stormwater Systems", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Asset Footprints') {
                          var template = new esri.InfoTemplate("Asset Footprints", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      else if (result.layerName === 'Playa Lakes') {
                          var template = new esri.InfoTemplate("Playa Lakes", "${*}")
                          feature.setInfoTemplate(template);
                      }
                      map.infoWindow.setFeatures([deferred]);
                      map.infoWindow.show(evt.mapPoint);
                      return feature;
                  });
              });
          }
0 Kudos
KenBuja
MVP Esteemed Contributor
Have you tried a case that doesn't use a secured service?
0 Kudos
NicholasKnabe
New Contributor
No I haven't. The web application I'm working on is directly for a city. If i changed the identifyparams and layerIds to just one layer then it ID's that one layer but when I add all the different layers and then change it to visible it still just ID's every layer. Just really confused and I know I'm not a programmer but trying to understand why it is not working. I tried to re do your example from about a month ago when we talked about this as well and I just cannot replicate what you were doing in your fiddle in my code.

Sorry
0 Kudos