<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Accessing the map object from within a button click event in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/accessing-the-map-object-from-within-a-button/m-p/862349#M11924</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That worked.&amp;nbsp; Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 May 2015 23:05:40 GMT</pubDate>
    <dc:creator>TomFlahive</dc:creator>
    <dc:date>2015-05-19T23:05:40Z</dc:date>
    <item>
      <title>Accessing the map object from within a button click event</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/accessing-the-map-object-from-within-a-button/m-p/862347#M11922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to create a Web AppBuilder custom widget.&amp;nbsp; 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).&amp;nbsp; See attached screenshot of widget. &lt;/P&gt;&lt;P&gt;But I am having trouble figuring out how to correctly access the map object from within a button click event.&amp;nbsp; Here is basically what I am trying to do in a simplified way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;startup: function() {
&amp;nbsp; this.inherited(arguments);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; // This alert can access the map graphics layer ID's.
&amp;nbsp; alert ("Show ID's (this works): " + this.map.graphicsLayerIds)
&amp;nbsp; 
&amp;nbsp; on(dom.byId("widget_button"), "click", function() { 
&amp;nbsp;&amp;nbsp; // This alert results in error.
&amp;nbsp;&amp;nbsp; alert ("Show map ID (this DOES NOT work): " + this.map.graphicsLayerIds)
&amp;nbsp; });&amp;nbsp; 
 }&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm sure it has to do with scoping, and I've tried different ways, but am not having much success.&amp;nbsp; 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.&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:41:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/accessing-the-map-object-from-within-a-button/m-p/862347#M11922</guid>
      <dc:creator>TomFlahive</dc:creator>
      <dc:date>2021-12-12T10:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing the map object from within a button click event</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/accessing-the-map-object-from-within-a-button/m-p/862348#M11923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom this is how I do it. below startup write&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var mymap = this.map;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now you can just use mymap within other functions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 17:31:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/accessing-the-map-object-from-within-a-button/m-p/862348#M11923</guid>
      <dc:creator>TimWitt2</dc:creator>
      <dc:date>2015-05-19T17:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing the map object from within a button click event</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/accessing-the-map-object-from-within-a-button/m-p/862349#M11924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That worked.&amp;nbsp; Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 23:05:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/accessing-the-map-object-from-within-a-button/m-p/862349#M11924</guid>
      <dc:creator>TomFlahive</dc:creator>
      <dc:date>2015-05-19T23:05:40Z</dc:date>
    </item>
  </channel>
</rss>

