There is an example of clipping map layers to a polygon in the ProSnippets for Map Authoring using the SetClipGeometry method. Is there also an API to exclude map layers from the clipping? The ArcGIS Pro map Clip Layers tab provides this capability.
Hi Lesley,
Unfortunately there is no SetClipGeometry method that allows you to exclude map layers from a clip geometry. However there is a property on the CIMMap object that allows you to specify the layers. The property is called LayersExcludedFromClipping.
</code></pre><P> </P><P> </P><P>Here's a small sample of how you would use it. </P><P> </P><pre class="lia-code-sample language-csharp"><code> // find the first layer in the map var layer = MapView.Active.Map.GetLayersAsFlattenedList().FirstOrDefault(); if (layer == null) return; // create a list of strings List<string> layerUris = new List<string>(); // add the layer URI to the list layerUris.Add(layer.URI); QueuedTask.Run(() => { // create a polygon from the current extent var poly = PolygonBuilder.CreatePolygon(MapView.Active.Extent); // set the clip geometry MapView.Active.Map.SetClipGeometry(poly, null); // get the map definition var mapDef = MapView.Active.Map.GetDefinition(); // assign the layers to be excluded mapDef.LayersExcludedFromClipping = layerUris.ToArray(); // set the map definition MapView.Active.Map.SetDefinition(mapDef); });
Let me know if you have any questions.
We'll update the SetClipGeometry method to include the option to exclude layers in a future release.
Thanks
Narelle
Thank you! This worked well. I retrieved a polygon from a feature class to set my clip geometry. Wish I were more competent in LINQ queries when querying the layers to exclude from the clipping, but I got it working!
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.