Hi
Have the limitations for LayerCreationParams been fixed for 2.5 or greater? I really need to change visibility for layers and set definitions too.
See this link if you are unsure what I'm talking about (bit where it mentions KNOWN LIMIT):
https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Map-Authoring#layer-files-and-layer-packages
Kind regards.
Hi,
I can confirm that the ability to create a Layer Document from a Lyrx file saved on Portal has been added to 2.8. 2.8 is currently under development.
ArcPro 2.8 will be released later this year.
Thanks!
Uma
@UmaHarano Is there any update on this?
Hi Simon,
These LayerDocument issues have been reported to the development team. We will prioritize adding these requirements for a future near term release.
Thank you for all your feedback!
Hi Uma,
Thanks for getting back to me. This is disappointing for us, I really do hope ESRI fix this sooner rather than later as it is hampering and degrading the user experience for our add in.
Anyway fingers crossed.
Kind regards
Simon.
Hi Simon
Looks like the portal item URL cannot be passed to the Layer Document at this time.
We will prioritize adding this requirement for a future near term release.
I've tried :
<SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;">var</SPAN> layerDoc <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">=</SPAN> <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit;">new</SPAN> <SPAN class="" style="border: 0px; font-weight: inherit;">LayerDocument</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(portalItemUrl</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">;</SPAN>
with the portal item (which is a .lyrx file) and it returns null. Is there any way to make the code that you outlined in your answer work with portal layer items?
The example looks like it only works with physical layer files on disk - however I am working with layer files from the portal and they com back as type Core.Item. Does this work with portal layer items? and can I position/set the index of the layer in the contents? like I can with the one of the overrides on the CreateLayer().
This limitation still exists. The Pro development team is looking at fixes.
In the meantime, you can access the LayerDocument and the CIM Definition to accomplish what you need -
<SPAN class="comment token">// create a layer and add it to a groupLayer</SPAN> <SPAN class="keyword token">string</SPAN> urlLyrx <SPAN class="operator token">=</SPAN> <SPAN class="string token">@"\\path\States.lyrx"</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="keyword token">var</SPAN> layerDoc <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">LayerDocument</SPAN><SPAN class="punctuation token">(</SPAN>urlLyrx<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> cimlyrDoc <SPAN class="operator token">=</SPAN> layerDoc<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetCIMLayerDocument</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> defn <SPAN class="operator token">=</SPAN> cimlyrDoc<SPAN class="punctuation token">.</SPAN>LayerDefinitions<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">as</SPAN> CIMFeatureLayer<SPAN class="punctuation token">;</SPAN> defn<SPAN class="punctuation token">.</SPAN>Visibility <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">;</SPAN> defn<SPAN class="punctuation token">.</SPAN>Name <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Test Layer"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//defn.Renderer = ..</SPAN> <SPAN class="comment token">//defn.DisplayFilters = </SPAN> <SPAN class="comment token">//etc</SPAN> <SPAN class="keyword token">var</SPAN> createParams <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">LayerCreationParams</SPAN><SPAN class="punctuation token">(</SPAN>cimlyrDoc<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> FeatureLayer flyr <SPAN class="operator token">=</SPAN> LayerFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN>CreateLayer<SPAN class="operator token"><</SPAN>FeatureLayer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN>createParams<SPAN class="punctuation token">,</SPAN> MapView<SPAN class="punctuation token">.</SPAN>Active<SPAN class="punctuation token">.</SPAN>Map<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></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Thanks
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.