<?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: Graphic position on the map (not lat/long) in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634367#M16312</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think the issue is when the code MapToScreen() is executed. It needs to be run when the layers are drawn to your map. Try to execute it in the LayersInitialized handler.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp; public MainPage()
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; InitializeComponent();
&amp;nbsp;&amp;nbsp; this.MyMap.Layers.LayersInitialized += Layers_LayersInitialized;
&amp;nbsp; }

&amp;nbsp; bool allLayersDrawn = false;
&amp;nbsp; void Layers_LayersInitialized(object sender, System.EventArgs args)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; if (!allLayersDrawn)
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; GraphicsLayer l = this.MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (l != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MapPoint mapPoint = l.Graphics[0].Geometry.Extent.GetCenter();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Point screenPoint = this.MyMap.MapToScreen(mapPoint);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; allLayersDrawn = true;
&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp; 
&amp;nbsp; }
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 02:59:25 GMT</pubDate>
    <dc:creator>JenniferNery</dc:creator>
    <dc:date>2021-12-12T02:59:25Z</dc:date>
    <item>
      <title>Graphic position on the map (not lat/long)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634360#M16305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I wanted to find out where in the map does a graphic layer lie (coordinate in the map layer, not the geographic latitude/longitude), how can I do so?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2011 13:08:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634360#M16305</guid>
      <dc:creator>SangamLama</dc:creator>
      <dc:date>2011-01-07T13:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic position on the map (not lat/long)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634361#M16306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not entirely sure what you mean, but have you looked at the Map.ScreenToMap and Map.MapToScreen methods? They might do what you are looking for.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2011 18:00:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634361#M16306</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2011-01-07T18:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic position on the map (not lat/long)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634362#M16307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm not entirely sure what you mean, but have you looked at the Map.ScreenToMap and Map.MapToScreen methods? They might do what you are looking for.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;based on the provided description, looks likethat's exactly what I need. But, I get X and Y as NaN respectively. Any idea why that might be happening? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here's what I've done:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MapPoint p1 = new MapPoint();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p1.X = (graphic.Geometry.Extent.XMax + graphic.Geometry.Extent.XMin)/2; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p1.Y = (graphic.Geometry.Extent.YMax + graphic.Geometry.Extent.YMin)/2; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Point p2 = MyMap.MapToScreen(p1);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(p1.X = -70 and p2.Y = 40 approximately)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And the map layer is within a canvas in SL application. Since the function appears to compute the screen coordinates relative to the upper left of the map control, I don't see why the results yield NaN....&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2011 18:35:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634362#M16307</guid>
      <dc:creator>SangamLama</dc:creator>
      <dc:date>2011-01-07T18:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic position on the map (not lat/long)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634363#M16308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not sure what your calculation is trying to achieve but referring to your first post, to find out the position of a graphic, you can use mouse events on the layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this SDK example (Identify), MouseClick event is used and e.MapPoint gives the location using map coordinates.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Identify"&gt;http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Identify&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this SDK example (Mouse Coords), MouseMove event is used to get both MapPoint and ScreenPoint.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#MouseCoords"&gt;http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#MouseCoords&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As Morten mentioned, it is possible to convert from one coordinate system to the other by calling MapToScreen or ScreenToMap.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jan 2011 03:43:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634363#M16308</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2011-01-09T03:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic position on the map (not lat/long)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634364#M16309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jennifer, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to simulate a mouseleftbuttondown event on the graphic instead of actually performing it. There's a popup window tied to certain graphics on the map. When one clicks any of those graphic layers, the popup window appears with certain XY mouse offset. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But later on I ran into the need of displaying that popup window without clicking on the graphic. In order to get that offset without an actual click, I needed a function such as MapToScreen. But my implementation doesn't work. Since my question would have been too detailed the first time around, I only asked a part of it. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll try a couple more ways to see if it works. If anyone else has a better approach, please do tell &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm not sure what your calculation is trying to achieve but referring to your first post, to find out the position of a graphic, you can use mouse events on the layer.&lt;BR /&gt;&lt;BR /&gt;In this SDK example (Identify), MouseClick event is used and e.MapPoint gives the location using map coordinates.&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Identify"&gt;http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Identify&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;In this SDK example (Mouse Coords), MouseMove event is used to get both MapPoint and ScreenPoint.&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#MouseCoords"&gt;http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#MouseCoords&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;As Morten mentioned, it is possible to convert from one coordinate system to the other by calling MapToScreen or ScreenToMap.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jan 2011 12:03:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634364#M16309</guid>
      <dc:creator>SangamLama</dc:creator>
      <dc:date>2011-01-10T12:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic position on the map (not lat/long)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634365#M16310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How about...&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
MapPoint mapPoint = graphic.Extent.GetCenter(); 
Point screenPoint = MyMap.MapToScreen(mapPoint);
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;provided neither graphic nor its extent is null.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:59:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634365#M16310</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2021-12-12T02:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic position on the map (not lat/long)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634366#M16311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;How about...&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
MapPoint mapPoint = graphic.Extent.GetCenter(); 
Point screenPoint = MyMap.MapToScreen(mapPoint);
&lt;/PRE&gt;&lt;BR /&gt;provided neither graphic nor its extent is null.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried this, but I still get the value of screenPoint as NaN, NaN. Neither graphic or extent is null.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:59:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634366#M16311</guid>
      <dc:creator>SangamLama</dc:creator>
      <dc:date>2021-12-12T02:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Graphic position on the map (not lat/long)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634367#M16312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think the issue is when the code MapToScreen() is executed. It needs to be run when the layers are drawn to your map. Try to execute it in the LayersInitialized handler.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp; public MainPage()
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; InitializeComponent();
&amp;nbsp;&amp;nbsp; this.MyMap.Layers.LayersInitialized += Layers_LayersInitialized;
&amp;nbsp; }

&amp;nbsp; bool allLayersDrawn = false;
&amp;nbsp; void Layers_LayersInitialized(object sender, System.EventArgs args)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp; if (!allLayersDrawn)
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; GraphicsLayer l = this.MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (l != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MapPoint mapPoint = l.Graphics[0].Geometry.Extent.GetCenter();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Point screenPoint = this.MyMap.MapToScreen(mapPoint);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; allLayersDrawn = true;
&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp; 
&amp;nbsp; }
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:59:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/graphic-position-on-the-map-not-lat-long/m-p/634367#M16312</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2021-12-12T02:59:25Z</dc:date>
    </item>
  </channel>
</rss>

