<?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: Add a floating graphic to Map in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1198690#M8552</link>
    <description>&lt;P&gt;Thanks guys.&amp;nbsp; So the problem was with my CrossHairControl.&amp;nbsp; Once I deleted it and created a new one, all is good.&amp;nbsp; No issues with the threading.&amp;nbsp; Thanks for all your help with this!!&lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2022 19:14:49 GMT</pubDate>
    <dc:creator>BrianBulla</dc:creator>
    <dc:date>2022-08-02T19:14:49Z</dc:date>
    <item>
      <title>Add a floating graphic to Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1196730#M8509</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Is it possible to add a graphic to the active Map that floats in space and doesn't change position when panning the map?&amp;nbsp; What I want to do is have a cross-hair type graphic centred around the centre of the map, and when the user pans around I will then use the Maps camera co-ordinate to do things with.&lt;/P&gt;&lt;P&gt;Hopefully that makes sense.&amp;nbsp; I've added graphics before, but they've always been tied to a specific location on the map, and hence move with the map when panning.&amp;nbsp; I kind of want the opposite effect.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 13:31:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1196730#M8509</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2022-07-28T13:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Add a floating graphic to Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1197636#M8533</link>
      <description>&lt;P&gt;you want a "MapViewOverlayControl". It is, essentially, a wrapper around a "standard" WPF User Control that u can add to the MapView control overlay. This overlay is used by Pro for user control content (as opposed to graphics elements content) - such as the Time slider, Edit sketch toolbar, Navigation tool "compass/navigator", and so on that sits "on top of" the map view.&lt;/P&gt;&lt;P&gt;To use it, create a user control - in this case it sounds like it will be something like a WPF canvas that contains your cross-hair image, centered. Wrap the user control with a MapViewOverlayControl and then add _that_ to the map view control overlay with mapView.AddOverlayerControl(....) :&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic17220.html" target="_self"&gt;MapViewOverlayControl&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You should also look at the scribble control sample - it uses the map view overlay to hold a scribble control allowing users to "scribble" or "annotate" markup directly on top of the mapview (via a MapViewOverlayControl wrapping the scribble control).&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/ScribbleControl_ArcGISPro" target="_self"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/ScribbleControl_ArcGISPro&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code to add the overlay control will look something like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var crossHairControl = new CrossHairControl(); //your user control
//do any required configuration upfront
crossHairControl.Foo = ....;
crossHairControl.Bar = ....;

//Create a MapViewOverlayControl. 
var mapViewOverlayControl = new MapViewOverlayControl(
      crossHairControl, true, true, 
      true, OverlayControlRelativePosition.Center, .5, .8);
//Add to the active map view
MapView.Active.AddOverlayControl(mapViewOverlayControl);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 21:54:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1197636#M8533</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2022-07-29T21:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Add a floating graphic to Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1197724#M8535</link>
      <description>&lt;P&gt;Charlie's suggestion is the way to go, however, you have to compute the x/y ratios to position the user control in the middle of the screen.&amp;nbsp; For that you have the use the active mapview's GetViewSize().&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;if (MapView.Active == null) return;
var mapView = MapView.Active;
var crossHairControl = new CrossHairControl();
// use the active mapview to get the size of the mapview display
var xRatio = 0.0;
var yRatio = 0.0;
var viewSize = mapView.GetViewSize();
if (viewSize.Width != 0.0 &amp;amp;&amp;amp; viewSize.Height != 0.0)
{
  var xPosition = viewSize.Width / 2;
  var yPosition = viewSize.Height / 2;
  // now offset for 1/2 of the user control's size
  xPosition -= 16;
  yPosition -= 16;
  xRatio = xPosition / viewSize.Width;
  yRatio = yPosition / viewSize.Height;
}
// Create a MapViewOverlayControl using the user control
var mapViewOverlayControl = new MapViewOverlayControl(
      crossHairControl, true, false,
      false, OverlayControlRelativePosition.Center, xRatio, yRatio);
//Add to the active map view
mapView.AddOverlayControl(mapViewOverlayControl);&lt;/LI-CODE&gt;&lt;P&gt;I attached my sample add-in, but the result should look like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Wolf_0-1659197053983.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/47325i75AC6D6A0D04DA2F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Wolf_0-1659197053983.png" alt="Wolf_0-1659197053983.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jul 2022 16:06:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1197724#M8535</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2022-07-30T16:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Add a floating graphic to Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1198543#M8548</link>
      <description>&lt;P&gt;Thanks guys.&amp;nbsp; The sample code you both have given is a great help.&amp;nbsp; One issue I am having is adding the crosshair using a CheckBox in my WPF Dockpane.&amp;nbsp; The code seems to run, but then I get an exception saying "page can only have window or frame as parent".&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrianBulla_0-1659450911553.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/47584i5F27D3567D9FC18A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrianBulla_0-1659450911553.png" alt="BrianBulla_0-1659450911553.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my Dockpane.xaml.cs I have this (basically the same as Wolf's code), and then the exception happens after the last line runs.&amp;nbsp; The code seems to be calculating the width/height ok so it seems like I can interact with the MapView.&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private void chkCrossHair_Checked(object sender, RoutedEventArgs e)
        {
            //draw a cross-hair in centre of active map
            
            if (MapView.Active == null) return;

            var mapView = MapView.Active;
            var crossHairControl = new CrossHairControl();

            //use the active mapview to get the size of the mapview display
            var xRatio = 0.0;
            var yRatio = 0.0;
            var viewSize = mapView.GetViewSize();

            if (viewSize.Width != 0.0 &amp;amp;&amp;amp; viewSize.Height != 0.0)
            {
                var xPosition = viewSize.Width / 2;
                var yPosition = viewSize.Height / 2;
                // now offset for 1/2 of the user control's size
                xPosition -= 16;
                yPosition -= 16;
                xRatio = xPosition / viewSize.Width;
                yRatio = yPosition / viewSize.Height;
            }

            // Create a MapViewOverlayControl using the user control
            var mapViewOverlayControl = new MapViewOverlayControl(
                  crossHairControl, true, false,
                  false, OverlayControlRelativePosition.Center, xRatio, yRatio);
            //Add to the active map view
            mapView.AddOverlayControl(mapViewOverlayControl);

        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 14:39:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1198543#M8548</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2022-08-02T14:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Add a floating graphic to Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1198608#M8550</link>
      <description>&lt;P&gt;you have a threading issue. Usually an InvalidOperation exception is thrown when u create something on the _background_ thread that needs to be created on the UI thread (the reverse of most cases w the Pro SDK which do require u to use the QTR).&lt;/P&gt;&lt;P&gt;However it's not possible to tell from just this snippet. Make sure that the complete sequence occurs on the UI thread in this case.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 16:10:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1198608#M8550</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2022-08-02T16:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Add a floating graphic to Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1198666#M8551</link>
      <description>&lt;P&gt;Like Charles said we don't have enough code to see the problem, but i would also check your&amp;nbsp;CrossHairControl and make sure that&amp;nbsp;mapViewOverlayControl is defined.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 18:09:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1198666#M8551</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2022-08-02T18:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Add a floating graphic to Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1198690#M8552</link>
      <description>&lt;P&gt;Thanks guys.&amp;nbsp; So the problem was with my CrossHairControl.&amp;nbsp; Once I deleted it and created a new one, all is good.&amp;nbsp; No issues with the threading.&amp;nbsp; Thanks for all your help with this!!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 19:14:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/add-a-floating-graphic-to-map/m-p/1198690#M8552</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2022-08-02T19:14:49Z</dc:date>
    </item>
  </channel>
</rss>

