I'm using the WPF ArcGIS Runtime SDK for .Net v100.0.0.0. The application is consuming an mmpk. After a DefinitionExpression is applied to a FeatureLayer, the labels of the features are no longer displayed. How do I get them back?
Hi Jeff,
This is an issue we're aware of and it is resolved for our next release early this summer. In the meantime, you could use a GraphicsOverlay as a workaround for your labels
<SPAN class="comment token">// Run query to get all the features in the visible area</SPAN> <SPAN class="keyword token">var</SPAN> featureLayer <SPAN class="operator token">=</SPAN> mapView<SPAN class="punctuation token">.</SPAN>Map<SPAN class="punctuation token">.</SPAN>OperationalLayers<SPAN class="punctuation token">[</SPAN>layerIndex<SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">as</SPAN> FeatureLayer<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>featureLayer <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> featureTable <SPAN class="operator token">=</SPAN> featureLayer<SPAN class="punctuation token">.</SPAN>FeatureTable<SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Set query parameters</SPAN> <SPAN class="keyword token">var</SPAN> queryParams <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">QueryParameters</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> ReturnGeometry <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">,</SPAN> Geometry <SPAN class="operator token">=</SPAN> mapView<SPAN class="punctuation token">.</SPAN>VisibleArea <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Query the feature table </SPAN> <SPAN class="keyword token">var</SPAN> queryResult <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">await</SPAN> roomsTable<SPAN class="punctuation token">.</SPAN><SPAN class="token function">QueryFeaturesAsync</SPAN><SPAN class="punctuation token">(</SPAN>queryParams<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Query using the def query expression</SPAN> <SPAN class="keyword token">var</SPAN> labelFeatures <SPAN class="operator token">=</SPAN> queryResult<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Where</SPAN><SPAN class="punctuation token">(</SPAN>f <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> f<SPAN class="punctuation token">.</SPAN>Attributes<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"DefQueryColumn"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToString</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">"QueryExpression"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>labelFeatures <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">try</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> graphicsOverlay <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>MapView<SPAN class="punctuation token">.</SPAN>GraphicsOverlays<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"LabelsGraphicsOverlay"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN> graphicsOverlay<SPAN class="punctuation token">.</SPAN>Graphics<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Clear</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Run garbage collector manually to prevent System.ArgumentException </SPAN> GC<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Collect</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> GC<SPAN class="punctuation token">.</SPAN><SPAN class="token function">WaitForPendingFinalizers</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">foreach</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">var</SPAN> feature <SPAN class="keyword token">in</SPAN> labelFeatures<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> centerPoint <SPAN class="operator token">=</SPAN> feature<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>Extent<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetCenter</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> label <SPAN class="operator token">=</SPAN> feature<SPAN class="punctuation token">.</SPAN>Attributes<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"LabelAttribute"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>label <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">// Create graphic</SPAN> <SPAN class="keyword token">var</SPAN> labelText <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">TextSymbol</SPAN><SPAN class="punctuation token">(</SPAN>label<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToString</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> System<SPAN class="punctuation token">.</SPAN>Drawing<SPAN class="punctuation token">.</SPAN>Color<SPAN class="punctuation token">.</SPAN>Black<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">10</SPAN><SPAN class="punctuation token">,</SPAN> HorizontalAlignment<SPAN class="punctuation token">.</SPAN>Center<SPAN class="punctuation token">,</SPAN> VerticalAlignment<SPAN class="punctuation token">.</SPAN>Middle<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> labelGraphic <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Graphic</SPAN><SPAN class="punctuation token">(</SPAN>centerPoint<SPAN class="punctuation token">,</SPAN> labelText<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Add label to map</SPAN> graphicsOverlay<SPAN class="punctuation token">.</SPAN>Graphics<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Add</SPAN><SPAN class="punctuation token">(</SPAN>labelGraphic<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="keyword token">catch</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></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><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></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.