Is there a event in ArcGIS Pro SDK for .NET (C#) which occurs whenever a datum transformation is changed?#
Hi
You can use the MapPropertyChangedEvent. When you change the datum transformation on a map, this event is fired. You can subscribe to this event in your module class. Below is a code snippet that subscribes to the event, and an event handler that is called when it triggers. In the event handler, we check the Map Definition's DatumTransforms or HVDatumTransforms property to get the changed value.
Note: Store the current (previous) values for the Datum also in the module class to compare with the changed value you get from the event handler.
Thanks
Uma
<SPAN class="keyword token">protected</SPAN> <SPAN class="keyword token">override</SPAN> <SPAN class="keyword token">bool</SPAN> <SPAN class="token function">Initialize</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> MapPropertyChangedEvent<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Subscribe</SPAN><SPAN class="punctuation token">(</SPAN>OnMapPropertyChanged<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="keyword token">base</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">Initialize</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">OnMapPropertyChanged</SPAN><SPAN class="punctuation token">(</SPAN>MapPropertyChangedEventArgs obj<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>obj<SPAN class="punctuation token">.</SPAN>EventHints<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Any</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>MapView<SPAN class="punctuation token">.</SPAN>Active<SPAN class="punctuation token">.</SPAN>Map <SPAN class="keyword token">is</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">return</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> cimMapDefinition <SPAN class="operator token">=</SPAN> MapView<SPAN class="punctuation token">.</SPAN>Active<SPAN class="punctuation token">.</SPAN>Map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetDefinition</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> datumTransformations <SPAN class="operator token">=</SPAN> cimMapDefinition<SPAN class="punctuation token">.</SPAN>DatumTransforms<SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// use if map's sr does not have a vertical coordinate system</SPAN> <SPAN class="keyword token">var</SPAN> hvDatumTransformations <SPAN class="operator token">=</SPAN> cimMapDefinition<SPAN class="punctuation token">.</SPAN>HVDatumTransforms<SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// use if map's sr has a vertical coordinate system</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></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.