Have anyone converted a xy coordinate to lat/long using Pro SDK? I just could not get the correct numbers.
Hi Fayu,
You can use this code snippet:
<SPAN class="keyword token">return</SPAN> QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> activeMapView <SPAN class="operator token">=</SPAN> MapView<SPAN class="punctuation token">.</SPAN>Active<SPAN class="punctuation token">;</SPAN> MapPoint zoomToPnt <SPAN class="operator token">=</SPAN> MapPointBuilder<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreateMapPoint</SPAN><SPAN class="punctuation token">(</SPAN>coord<SPAN class="punctuation token">.</SPAN>Longitude<SPAN class="punctuation token">,</SPAN> coord<SPAN class="punctuation token">.</SPAN>Latitude<SPAN class="punctuation token">,</SPAN> SpatialReferences<SPAN class="punctuation token">.</SPAN>WGS84<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> projectedXY <SPAN class="operator token">=</SPAN> GeometryEngine<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN>Project <SPAN class="punctuation token">(</SPAN>zoomToPnt<SPAN class="punctuation token">,</SPAN> activeMapView<SPAN class="punctuation token">.</SPAN>Map<SPAN class="punctuation token">.</SPAN>SpatialReference<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> MapPoint<SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
There are multiple samples among the community samples that use projection, just search for "Instance.Project" on the community samples GitHub repo for a list of usages.
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.