<?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: Access AddOverlay-method in MapTool from Module / ViewModel in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/access-addoverlay-method-in-maptool-from-module/m-p/1280648#M9723</link>
    <description>&lt;P&gt;This worked like a charm. Thanks a bunch Wolf, this makes it so much easier to work with graphics when I gain access to the MapTool overlay instead.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Apr 2023 09:22:38 GMT</pubDate>
    <dc:creator>TorRøkkumBørset</dc:creator>
    <dc:date>2023-04-20T09:22:38Z</dc:date>
    <item>
      <title>Access AddOverlay-method in MapTool from Module / ViewModel</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/access-addoverlay-method-in-maptool-from-module/m-p/1279589#M9699</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I am trying to create a MapTool that allows the user to find a location based on a string road reference.&lt;/P&gt;&lt;P&gt;The user can enter the road reference in a textblock in an Embeddable Control, and hit enter or click a search button, and the maptool will then send a request to an API that returns the coordinates of&amp;nbsp;&amp;nbsp;the road reference. &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="d5edf2ae-3a63-47b0-bcc5-1d995291df90.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/68242iA48BDA7C4C53403F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="d5edf2ae-3a63-47b0-bcc5-1d995291df90.png" alt="d5edf2ae-3a63-47b0-bcc5-1d995291df90.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The coordinates is then used to make a mappoint that is added to the map as a graphic. And I also want these graphics to be disposed when the maptool is closed.&lt;/P&gt;&lt;P&gt;I have bound a ICommand in the EmbeddableControls viewmodel, to the textblock and search button which in turn run a method in Module1 which handles the search-request to the road-reference API.&lt;/P&gt;&lt;P&gt;I can add the graphic to the MapView via &lt;EM&gt;MapView.Active.AddOverlay,&lt;/EM&gt; however this creates a problem as the graphic will not be disposed automatically when the tool is deactivated.&lt;/P&gt;&lt;P&gt;Preferably I would rather use the active maptools &lt;EM&gt;AddOverlay&lt;/EM&gt; method to add the graphics there, but I can’t figure out how to get access to the tools AddOverlay-method in Module1 or the viewmodel. I have tried to store the maptool-instance in both Module1 and the viewmodel for the embeddable control, but this has not worked.&lt;/P&gt;&lt;P&gt;Is there some other way to get access to the active maptool in a module or the viewmodel? I am in no way experienced with C#, so my attempts on solving this is more akin to throwing spaghetti at the wall and seeing what sticks.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Any help on this is much appreciated as I am thoroughly stuck in a rut.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;BR /&gt;Tor&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 10:28:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/access-addoverlay-method-in-maptool-from-module/m-p/1279589#M9699</guid>
      <dc:creator>TorRøkkumBørset</dc:creator>
      <dc:date>2023-04-18T10:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: Access AddOverlay-method in MapTool from Module / ViewModel</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/access-addoverlay-method-in-maptool-from-module/m-p/1279694#M9701</link>
      <description>&lt;P&gt;You can use the AddOverlay and AddOverlayAsync methods that are available for the MapView class:&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Map-Exploration#mapview-graphic-overlay" target="_blank" rel="noopener"&gt;ProConcepts Map Exploration · Esri/arcgis-pro-sdk Wiki (github.com)&lt;/A&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic9965.html" target="_blank" rel="noopener"&gt;AddOverlay Method (MappingExtensions)—ArcGIS Pro&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Or you can look at the attached sample that stores a reference to the MapTool in the Module class and uses the MapTools AddOverlay method.&amp;nbsp; &amp;nbsp;However, when you switch the tool the map point on the map will disappear.&amp;nbsp; The tool looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Wolf_0-1681838953619.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/68290iB930C03D32170F42/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Wolf_0-1681838953619.png" alt="Wolf_0-1681838953619.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 17:30:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/access-addoverlay-method-in-maptool-from-module/m-p/1279694#M9701</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2023-04-18T17:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Access AddOverlay-method in MapTool from Module / ViewModel</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/access-addoverlay-method-in-maptool-from-module/m-p/1279751#M9702</link>
      <description>&lt;P&gt;You had asked about clearing the graphics layer on closing the tool. I use a clearGraphics() overlay function that is called when the user clicks the Close button on the form Or changes to another tool.&amp;nbsp; You can catch the Deactivate event by adding this code in your primary namespace (i.e., the same module where you will find the OnToolActivateAsync() procedure).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;        protected override Task OnToolDeactivateAsync(bool hasMapViewChanged)
        {
            clearGraphics();
            return base.OnToolDeactivateAsync(hasMapViewChanged);
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2023 16:01:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/access-addoverlay-method-in-maptool-from-module/m-p/1279751#M9702</guid>
      <dc:creator>RichardDaniels</dc:creator>
      <dc:date>2023-04-18T16:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Access AddOverlay-method in MapTool from Module / ViewModel</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/access-addoverlay-method-in-maptool-from-module/m-p/1280648#M9723</link>
      <description>&lt;P&gt;This worked like a charm. Thanks a bunch Wolf, this makes it so much easier to work with graphics when I gain access to the MapTool overlay instead.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 09:22:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/access-addoverlay-method-in-maptool-from-module/m-p/1280648#M9723</guid>
      <dc:creator>TorRøkkumBørset</dc:creator>
      <dc:date>2023-04-20T09:22:38Z</dc:date>
    </item>
  </channel>
</rss>

