Listener for layer toggle widget

4884
68
Jump to solution
07-20-2018 07:37 AM
MarkLache1
New Contributor III

How would I add a listener to Robert's layer toggle widget that would be able to tell what layer is on? I want this so that the info can be passed into Survey123 via custom URL

Thanks

0 Kudos
68 Replies
RobertScheitlin__GISP
MVP Emeritus

Mark,

   Try defining the SERVICE_IS var at the beginning of the file then (line 14):

], function(declare, lang, array, html, query, topic, on, aspect, keys, i18n, dojoConfig, InfoWindow,
  PopupMobile, InfoTemplate, esriRequest, arcgisUtils, Extent, Point, require, jimuUtils,
  LayerInfos, Message, AppStatePopup, MapUrlParamsHandler, AppStateManager, PopupManager, FilterManager) {
  var instance = null,
    clazz = declare(null, {
      appConfig: null,
      mapDivId: '',
      map: null,
      previousInfoWindow: null,
      mobileInfoWindow: null,
      isMobileInfoWindow: false,

      layerInfosObj: null,
      SERVICE_ID: null,
0 Kudos
MarkLache1
New Contributor III

Robert,

Now its populated with "null"

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

I don't see how this is happening for you when the exact code I pasted is working fine on my side... Did you copy exactly what I had in my previous post?

0 Kudos
MarkLache1
New Contributor III

Very weird because its exactly the same. How about I email you my MapManager file?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mark,

   You do realize that you requested that the Service_ID only be set when a layer is toggled on right? So if you are just clicking on the map and have not used the layertoggle widget to toggle on a layer then the service_id would be null.

0 Kudos
MarkLache1
New Contributor III

Yes I have tested that. Even when I click the toggle it still returns null. There are 2 layers, one is on and the other is off at start. The toggle just switches the 2 layers.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Here is my MapManager.js

0 Kudos
MarkLache1
New Contributor III

Brought across the entire js file and no difference. There must be something different with your layers as it works for you but not me.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mark,

  You need to debug and add breakpoints (degugger;) to the code and check if the this.SERVICE_ID is getting set to something.

0 Kudos
MarkLache1
New Contributor III

Robert,

Debugging didn't really provide anything (see attached) unless I'm missing something

0 Kudos