Hi,
Following Uma Harano code on Drag & Drop into a DockPane , I am attempting to get the name and catalogue path of the payload that have been drag from the content pane.
if it possible to get the full catalogue path to the item selected?
Thanks
Hi Victor
To get the underlying featureclass path from a feature layer you'll have to concatenate the datastore path and the featureclass name. A code snippet like this worked for me:
<SPAN class="keyword token">var</SPAN> lyr <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">GetLayersAsFlattenedList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>OfType<SPAN class="operator token"><</SPAN>FeatureLayer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</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="comment token">//get the underlying featureclass path for the layer</SPAN> <SPAN class="keyword token">var</SPAN> fc <SPAN class="operator token">=</SPAN> lyr<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetFeatureClass</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//get the datastore for the featureclass</SPAN> <SPAN class="keyword token">var</SPAN> datastore <SPAN class="operator token">=</SPAN> fc<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetDatastore</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//concat hydrant path (datastore and featureclass name)</SPAN> <SPAN class="keyword token">var</SPAN> hydPath <SPAN class="operator token">=</SPAN> datastore<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetPath</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>AbsolutePath <SPAN class="operator token">+</SPAN> <SPAN class="string token">@"/"</SPAN> <SPAN class="operator token">+</SPAN> fc<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetName</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><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></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Uma
Thanks Uma,
Might be the environment I am working on. There must be something funky going on in the background as my sde connection seem to point to a temporary sde conn as I am positive that is not the right sde connection.
Hi Uma,
thats great if
dropInfo.Data is List<ClipboardItem> clipboardItems
however what if if it is a mapMember or layer?
<SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;">var</SPAN> mm <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">=</SPAN> dropInfo<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN><SPAN class="" style="color: #d74444; border: 0px; font-weight: inherit;">GetTOCContent</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">;</SPAN><SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;">//extension method - returns all MapMembers being dropped</SPAN> <SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;">//get just feature layers, for example</SPAN> <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;">var</SPAN> layers <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">=</SPAN> dropInfo<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>GetTOCContentOfType<SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;"><</SPAN>FeatureLayer<SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">></SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN>
I tried with the following:
layers[0].getFeatureClass().getDataStore().getPath() however I get a funny temporary sde connection in my temp folder.
Thanks in advance
The property to use is "CatalogPath".
The Drag and Drop sample is available here in the community sample repo: Drag and Drop sample
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.