Group layer does not play well with other tasks/widgets

834
2
Jump to solution
10-30-2017 08:56 AM
DouglasGreenfield
New Contributor III

I have a nice JSAPI app that incorporates search and locate widgets and an identify task (thank you Robert Scheitlin for your help!) When I try to add a Layer List widget with a group layer the identify task fails and my search widget disappears. It appears that I don't even need the widget (notice the commented out layer list code) as creating the group layer already adds this to my map. Therefore the Group Layer seems to be what's messing things up. I've attached the older code that works (version 247) and the code with the added group layer(347) as my ultimate goal is to allow users a choice of several map services to view as a basemaps. Any help out there?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Douglas,

   What I see right off in your browser347.html is your requires and subsequent vars are misaligned:

(line 6 was moved to match the order of your var names); AMD style programming needs the require list to have a exact order matching list of vars in the function.

The abc’s of AMD | ArcGIS Blog 

require([
      "esri/Map",
      "esri/views/MapView",
      "esri/layers/MapImageLayer",
      "esri/layers/GroupLayer",
      "esri/widgets/LayerList",
      "esri/tasks/IdentifyTask",
      "esri/tasks/support/IdentifyParameters",
      "esri/widgets/Search",
      "esri/widgets/Locate",
      "dojo/_base/array",
      "dojo/on",
      "dojo/dom",
      "dojo/domReady!"
    ], function(
      Map, MapView, MapImageLayer, GroupLayer, LayerList,
      IdentifyTask, IdentifyParameters, Search, Locate,
      arrayUtils, on, dom
    ) {

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Douglas,

   What I see right off in your browser347.html is your requires and subsequent vars are misaligned:

(line 6 was moved to match the order of your var names); AMD style programming needs the require list to have a exact order matching list of vars in the function.

The abc’s of AMD | ArcGIS Blog 

require([
      "esri/Map",
      "esri/views/MapView",
      "esri/layers/MapImageLayer",
      "esri/layers/GroupLayer",
      "esri/widgets/LayerList",
      "esri/tasks/IdentifyTask",
      "esri/tasks/support/IdentifyParameters",
      "esri/widgets/Search",
      "esri/widgets/Locate",
      "dojo/_base/array",
      "dojo/on",
      "dojo/dom",
      "dojo/domReady!"
    ], function(
      Map, MapView, MapImageLayer, GroupLayer, LayerList,
      IdentifyTask, IdentifyParameters, Search, Locate,
      arrayUtils, on, dom
    ) {
DouglasGreenfield
New Contributor III

Thanks! That along with a slight move in where I placed the previously commented out layer list code was all it took.

0 Kudos