AnsweredAssumed Answered

Accessing the map object from within a button click event

Question asked by TomFlahive on May 19, 2015
Latest reply on May 19, 2015 by TomFlahive

I am trying to create a Web AppBuilder custom widget.  The goal of the widget is to allow a user to fill in 3 text boxes (an ID and X,Y coordinates), and then when they click a button on the widget, the data will be submitted (using .applyEdits on a particular feature layer).  See attached screenshot of widget.

But I am having trouble figuring out how to correctly access the map object from within a button click event.  Here is basically what I am trying to do in a simplified way:


startup: function() {
  // This alert can access the map graphics layer ID's.
  alert ("Show ID's (this works): " +
  on(dom.byId("widget_button"), "click", function() { 
   // This alert results in error.
   alert ("Show map ID (this DOES NOT work): " +


I'm sure it has to do with scoping, and I've tried different ways, but am not having much success.  If someone could tell me how to properly access the map object--especially the map graphics layers--in a button click event, I would appreciate it.  Thanks.