<?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 Flex - removing graphics layer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/flex-removing-graphics-layer/m-p/425348#M39122</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I hope there is an easy answer to this that my lack of programming skills is just not seeing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've modified the default 3.6 Flex Print tool to add a print area box like you can find in Tom Schuller's custom print script, 'PChPrintSOE'.&amp;nbsp; I've been able to get everything to work - the print area responds to changes in the layout and scale and when you hit print it only prints what is inside the box.&amp;nbsp; The only problem I'm having now is getting the print area to go away when you close the widget.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought this would be simple but the WidgetTemplate that has the 'closed' event is in a different mxml from where the GraphicsLayer is declared and manipulated.&amp;nbsp; I just need 'hostBaseWidget.map.removeLayer(printGraphicsLayer);' to run when the 'wTemplate' in 'PrintWidget.mxml' is closed.&amp;nbsp; But the 'printGraphicsLayer' GraphicsLayer is in ExportWebMapForm.mxml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried adding an eventListener into 'ExportWebMapForm.mxml' but it either takes the graphic away at the wrong time or not at all.&amp;nbsp; I've tried declaring the GraphicsLayer in 'PrintWidget.mxml' and passing it to 'ExportWebMapForm.mxml' but haven't got that to work.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't consider myself a flex programmer so I'm hoping I'm missing something really obvious.&amp;nbsp; Tom's original script contains the WidgetTemplate and GraphicsLayer all in the same .mxml so he just set the 'closed' parameter on the WidgetTemplate to run a function to remove the GraphicsLayer - I just don't know how to do this when the WidgetTemplate and GraphicsLayer are in 2 different .mxml's.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a link to the site with the modified print tool: &lt;A href="http://arcgis.lakecountyohio.gov/flexviewer36/" title="http://arcgis.lakecountyohio.gov/flexviewer36/"&gt;ArcGIS Viewer for Flex&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help,&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Oct 2014 14:03:38 GMT</pubDate>
    <dc:creator>JimBranch</dc:creator>
    <dc:date>2014-10-06T14:03:38Z</dc:date>
    <item>
      <title>Flex - removing graphics layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/flex-removing-graphics-layer/m-p/425348#M39122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I hope there is an easy answer to this that my lack of programming skills is just not seeing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've modified the default 3.6 Flex Print tool to add a print area box like you can find in Tom Schuller's custom print script, 'PChPrintSOE'.&amp;nbsp; I've been able to get everything to work - the print area responds to changes in the layout and scale and when you hit print it only prints what is inside the box.&amp;nbsp; The only problem I'm having now is getting the print area to go away when you close the widget.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought this would be simple but the WidgetTemplate that has the 'closed' event is in a different mxml from where the GraphicsLayer is declared and manipulated.&amp;nbsp; I just need 'hostBaseWidget.map.removeLayer(printGraphicsLayer);' to run when the 'wTemplate' in 'PrintWidget.mxml' is closed.&amp;nbsp; But the 'printGraphicsLayer' GraphicsLayer is in ExportWebMapForm.mxml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried adding an eventListener into 'ExportWebMapForm.mxml' but it either takes the graphic away at the wrong time or not at all.&amp;nbsp; I've tried declaring the GraphicsLayer in 'PrintWidget.mxml' and passing it to 'ExportWebMapForm.mxml' but haven't got that to work.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't consider myself a flex programmer so I'm hoping I'm missing something really obvious.&amp;nbsp; Tom's original script contains the WidgetTemplate and GraphicsLayer all in the same .mxml so he just set the 'closed' parameter on the WidgetTemplate to run a function to remove the GraphicsLayer - I just don't know how to do this when the WidgetTemplate and GraphicsLayer are in 2 different .mxml's.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a link to the site with the modified print tool: &lt;A href="http://arcgis.lakecountyohio.gov/flexviewer36/" title="http://arcgis.lakecountyohio.gov/flexviewer36/"&gt;ArcGIS Viewer for Flex&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help,&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 14:03:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/flex-removing-graphics-layer/m-p/425348#M39122</guid>
      <dc:creator>JimBranch</dc:creator>
      <dc:date>2014-10-06T14:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Flex - removing graphics layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/flex-removing-graphics-layer/m-p/425349#M39123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I figured it out.&amp;nbsp; Here is the gist of it for anyone interested - or anyone who might want to point at a better way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of declaring the 'GraphicsLayer' in the ActionScript code I declared it as part of the &amp;lt;fx:Declarations&amp;gt; in the 'ExportWebMapFrom.mxml' that is opened by the 'PrintWidget.mxml'.&amp;nbsp; This allowed me to reference it from the 'PrintWidget.mxml'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I added the 'closed' and 'open' parameters in the WidgetTemplate inside of the 'PrintWidget.mxml' to open functions to change the visibility of the GraphicsLayer.&amp;nbsp; The biggest thing I was missing was the 'getLayer' function on the map object to retrieve the layer to change the visibility.&amp;nbsp; The actual code ended up being simple:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;private function wTemplate_closeHandler(event:Event):void&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; var myGraphicsLayer:GraphicsLayer = this.map.getLayer("printGraphicsLayer") as GraphicsLayer;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; myGraphicsLayer.visible = false;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;If anyone is interested in what this modified print widget does - it creates a graphic on the screen showing the extent of what is actually going to be printed to scale.&amp;nbsp; You can move the print area box around and it responds to changes from the widget's dropdowns like scale and page size.&amp;nbsp; For full disclosure, I've lifted all the custom code from Tom Schuller's 'PChPrintSOE' for this functionality.&amp;nbsp; Thanks Tom!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;Once again, here is the sample site showing it live: &lt;A href="http://arcgis.lakecountyohio.gov/flexviewer36/" title="http://arcgis.lakecountyohio.gov/flexviewer36/"&gt;ArcGIS Viewer for Flex&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Oct 2014 16:04:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/flex-removing-graphics-layer/m-p/425349#M39123</guid>
      <dc:creator>JimBranch</dc:creator>
      <dc:date>2014-10-08T16:04:16Z</dc:date>
    </item>
  </channel>
</rss>

