<?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: WebApp Builder - Adding layers in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821253#M7403</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hamish,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; When building widgets you have easy access to the map by using "this.map"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it would look something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14355394217468230 jive_text_macro" data-renderedposition="134_8_912_16" jivemacro_uid="_14355394217468230"&gt;&lt;P&gt;this.map.addLayer(yourLayer); &lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Jun 2015 00:56:52 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2015-06-29T00:56:52Z</dc:date>
    <item>
      <title>WebApp Builder - Adding layers</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821252#M7402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm working on developing a widget for Web App builder and what i'm trying to do is add a layer that has been created by the user in the web browser. In he JS API you can do something along the lines of:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;map.addLayer();&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However this is not working with the WebApp Builder. Below is the code I currently have with hard coded points:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var facilitiesGraphicsLayer = new GraphicsLayer();
facilitiesGraphicsLayer.setRenderer(Renderer);
facilitiesGraphicsLayer.add(new Graphic(new Point(1460355.1631064715,5082544.779264613,_viewerMap.__tileInfo.spatialReference))); /facilitiesGraphicsLayer.add(new Graphic(new Point(1564363.8936586068,5184488.835737464,_viewerMap.__tileInfo.spatialReference)));
facilitiesGraphicsLayer.add(new Graphic(new Point(1577894.9077129958,5222140.389124587,_viewerMap.__tileInfo.spatialReference))); 
facilitiesGraphicsLayer.add(new Graphic(new Point(1655876.6269847318,5306365.449387112,_viewerMap.__tileInfo.spatialReference))); 
facilities = new FeatureSet();
facilities.features = facilitiesGraphicsLayer.graphics;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I am after is (with a button press) the points in the facilities feature set to be added to the map.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is appreciated&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hamish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:44:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821252#M7402</guid>
      <dc:creator>HamishKingsbury1</dc:creator>
      <dc:date>2021-12-12T09:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: WebApp Builder - Adding layers</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821253#M7403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hamish,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; When building widgets you have easy access to the map by using "this.map"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it would look something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14355394217468230 jive_text_macro" data-renderedposition="134_8_912_16" jivemacro_uid="_14355394217468230"&gt;&lt;P&gt;this.map.addLayer(yourLayer); &lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jun 2015 00:56:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821253#M7403</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-06-29T00:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: WebApp Builder - Adding layers</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821254#M7404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brilliant, thank you. I am however running into another issue. Using the RouteTask Api (making a custom widget that requires inputs that can't be done by the directions widget) I can't display the returned route. Below is some of my code. The comment section is another of my attemps. Both of them dispaly the error '&lt;SPAN class="objectBox-errorMessage hasBreakSwitch objectBox"&gt;&lt;SPAN class="errorMessage"&gt;TypeError: this.Map.graphics is undefined'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// routeTask.on("solve-complete", function(evt){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; routeSymbol = new SimpleLineSymbol().setColor(new Color([0, 0, 255, 0.5])).setWidth(5);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; document.getElementById("routeResult").innerHTML = "Total Distance (optimized) is "+(((Math.round(evt.result.routeResults[0].directions.totalLength*100))/100).toFixed(2))+"kms.";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; toggle_visibility('calcloading','hide');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; route = evt.result.routeResults[0].route.setSymbol(routeSymbol);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.map.graphics.add(route);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; routeTask.on("solve-complete", this.this);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; routeTask.on("error",function(){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert('nay');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; toggle_visibility('calcloading','hide');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });

&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp; this: function(evt){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; routeSymbol = new SimpleLineSymbol().setColor(new Color([0, 0, 255, 0.5])).setWidth(5);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; document.getElementById("routeResult").innerHTML = "Total Distance (optimized) is "+(((Math.round(evt.result.routeResults[0].directions.totalLength*100))/100).toFixed(2))+"kms.";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; toggle_visibility('calcloading','hide');
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; route = evt.result.routeResults[0].route.setSymbol(routeSymbol);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.map.graphics.add(route);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var facilitiesGraphicsLayer = new GraphicsLayer(); facilitiesGraphicsLayer.setRenderer(Renderer); facilitiesGraphicsLayer.add(new Graphic(new Point(1460355.1631064715,5082544.779264613,_viewerMap.__tileInfo.spatialReference))); /facilitiesGraphicsLayer.add(new Graphic(new Point(1564363.8936586068,5184488.835737464,_viewerMap.__tileInfo.spatialReference))); facilitiesGraphicsLayer.add(new Graphic(new Point(1577894.9077129958,5222140.389124587,_viewerMap.__tileInfo.spatialReference)));&amp;nbsp; facilitiesGraphicsLayer.add(new Graphic(new Point(1655876.6269847318,5306365.449387112,_viewerMap.__tileInfo.spatialReference)));&amp;nbsp; facilities = new FeatureSet(); facilities.features = facilitiesGraphicsLayer.graphics;&lt;/PRE&gt;&lt;DIV style="display: none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:44:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821254#M7404</guid>
      <dc:creator>HamishKingsbury1</dc:creator>
      <dc:date>2021-12-12T09:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: WebApp Builder - Adding layers</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821255#M7405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hamish,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; From the looks of your code the context of "this" inside your function is not what it needs to be. It looks like you are defining this as a function and therefore "this" does not have a map property. You can use dojos lang.hitch to maintain context of "this" in your functions. If you look t any of the esri otb widget you will see many good examples of best practice coding you can follow.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jun 2015 01:32:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821255#M7405</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-06-30T01:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: WebApp Builder - Adding layers</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821256#M7406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for that, I've read through the documentation on the Dojo website however it is making little sense to me. I have also looked at some of the included widgets (Geocoder and LayerList) for how they use lang.hitch but again, that is not being overly helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you able to give a clear(ish) example?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jun 2015 01:44:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821256#M7406</guid>
      <dc:creator>HamishKingsbury1</dc:creator>
      <dc:date>2015-06-30T01:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: WebApp Builder - Adding layers</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821257#M7407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hamish,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; See if this thread helps any. If not I can try to go into more detail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/122105"&gt;lang.hitch what does it do?&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jun 2015 01:53:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821257#M7407</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-06-30T01:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: WebApp Builder - Adding layers</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821258#M7408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yay! thank you so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jun 2015 02:38:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/webapp-builder-adding-layers/m-p/821258#M7408</guid>
      <dc:creator>HamishKingsbury1</dc:creator>
      <dc:date>2015-06-30T02:38:36Z</dc:date>
    </item>
  </channel>
</rss>

