<?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 MapView is null in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/mapview-is-null/m-p/1311032#M10066</link>
    <description>&lt;P&gt;I have simple ArcObjects extension I'm porting over to Pro as an Add-In. I have it almost working, but my MapView is always coming back as null when I'm trying to zoom down to a section.&lt;/P&gt;&lt;P&gt;General idea of the tool: user enters in a section, township, and range or a parcel id(PID) number. It loads the parcel fabric from a mapx file I have sitting on a network drive(I am also testing loading the mapx file from Portal). The tool then zooms to the section or PID based on the user input.&lt;/P&gt;&lt;P&gt;Currently, it'll load the mapx file, select the section, but then tell me the MapView is null and will not zoom.&lt;/P&gt;&lt;P&gt;Here is a snippet of my code:&lt;/P&gt;&lt;P&gt;await QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; map = MapFactory.Instance.CreateMap(new Uri(mapxPath));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ProApp.Panes.CreateMapPaneAsync(map);&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;await QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; FeatureLayer mapLayer = GetMapLayer(map, "PLSS Section");&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; QueryFilter queryFilter = new QueryFilter { WhereClause = $"Name = '{sectionNumber}-{townshipNumber}-{rangeNumber}'" };&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; using (Selection sectionSelection = mapLayer.Select(queryFilter, SelectionCombinationMethod.New))&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ZoomToSelected();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The GetMapLayer is a separate function I have and does the obvious, gets the Map Layer called PLSS Section, so I can query it for the correct section.&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated. I'm guessing I'm overlooking something very simple. If I can't get it to work, then I'll create a separate Add-in to do the zooming down to the section or PID once the map is loaded but I'm hopeful I can get it to work with a little help from the community.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jul 2023 15:33:08 GMT</pubDate>
    <dc:creator>mhudson</dc:creator>
    <dc:date>2023-07-24T15:33:08Z</dc:date>
    <item>
      <title>MapView is null</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/mapview-is-null/m-p/1311032#M10066</link>
      <description>&lt;P&gt;I have simple ArcObjects extension I'm porting over to Pro as an Add-In. I have it almost working, but my MapView is always coming back as null when I'm trying to zoom down to a section.&lt;/P&gt;&lt;P&gt;General idea of the tool: user enters in a section, township, and range or a parcel id(PID) number. It loads the parcel fabric from a mapx file I have sitting on a network drive(I am also testing loading the mapx file from Portal). The tool then zooms to the section or PID based on the user input.&lt;/P&gt;&lt;P&gt;Currently, it'll load the mapx file, select the section, but then tell me the MapView is null and will not zoom.&lt;/P&gt;&lt;P&gt;Here is a snippet of my code:&lt;/P&gt;&lt;P&gt;await QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; map = MapFactory.Instance.CreateMap(new Uri(mapxPath));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ProApp.Panes.CreateMapPaneAsync(map);&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;await QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; FeatureLayer mapLayer = GetMapLayer(map, "PLSS Section");&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; QueryFilter queryFilter = new QueryFilter { WhereClause = $"Name = '{sectionNumber}-{townshipNumber}-{rangeNumber}'" };&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; using (Selection sectionSelection = mapLayer.Select(queryFilter, SelectionCombinationMethod.New))&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ZoomToSelected();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The GetMapLayer is a separate function I have and does the obvious, gets the Map Layer called PLSS Section, so I can query it for the correct section.&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated. I'm guessing I'm overlooking something very simple. If I can't get it to work, then I'll create a separate Add-in to do the zooming down to the section or PID once the map is loaded but I'm hopeful I can get it to work with a little help from the community.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 15:33:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/mapview-is-null/m-p/1311032#M10066</guid>
      <dc:creator>mhudson</dc:creator>
      <dc:date>2023-07-24T15:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: MapView is null</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/mapview-is-null/m-p/1311380#M10071</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Try code below:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;await QueuedTask.Run(() =&amp;gt;
{
    map = MapFactory.Instance.CreateMap(new Uri(mapxPath));
});

await ProApp.Panes.CreateMapPaneAsync(map);&lt;/LI-CODE&gt;&lt;P&gt;or&lt;/P&gt;&lt;LI-CODE lang="c"&gt;await QueuedTask.Run(async() =&amp;gt;
{
    map = MapFactory.Instance.CreateMap(new Uri(mapxPath));
    await ProApp.Panes.CreateMapPaneAsync(map);
});&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 25 Jul 2023 05:31:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/mapview-is-null/m-p/1311380#M10071</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2023-07-25T05:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: MapView is null</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/mapview-is-null/m-p/1313083#M10108</link>
      <description>&lt;P&gt;I apologize for not getting back to this sooner. Busy week!&lt;/P&gt;&lt;P&gt;Your simple change to the code worked. Thank you!&lt;/P&gt;&lt;P&gt;So it looks like I just didn't have the await in front of the ProApp call? I'll have to play around with this a little more as I actually had the exact line of code commented out but it was during some other testing for bringing a mapx file from Portal instead of from our network drive. I was running into the same issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;At least I have a solution that will work.&lt;/P&gt;&lt;P&gt;Thank you again!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 14:21:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/mapview-is-null/m-p/1313083#M10108</guid>
      <dc:creator>mhudson</dc:creator>
      <dc:date>2023-07-28T14:21:14Z</dc:date>
    </item>
  </channel>
</rss>

