Is there a built in state that is set when a polyline is selected? If not, is there a way to create a state that is set automatically when a polyline is selected or de-selected?
Hi
You can create your own state to check this - ProGuide: Code Your Own States and Conditions
If you subscribe to the MapSelectionChangedEvent, you will be able to see when the Selection changed. You can then check if any of the layers selected were of type PolyLine.
<SPAN class="comment token">//In the module class subscribe to the MapSelection Event.</SPAN> <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> MapSelectionChangedEvent<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Subscribe</SPAN><SPAN class="punctuation token">(</SPAN>OnMapSelectionChanged<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="comment token">//Event handler checks if the layer selected is a PolyLine.</SPAN> <SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">OnMapSelectionChanged</SPAN><SPAN class="punctuation token">(</SPAN>MapSelectionChangedEventArgs obj<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> item <SPAN class="keyword token">in</SPAN> obj<SPAN class="punctuation token">.</SPAN>Selection<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> featureLayer <SPAN class="operator token">=</SPAN> item<SPAN class="punctuation token">.</SPAN>Key <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="punctuation token">.</SPAN>ShapeType <SPAN class="operator token">==</SPAN> esriGeometryType<SPAN class="punctuation token">.</SPAN>esriGeometryPolyline<SPAN class="punctuation token">)</SPAN> MessageBox<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Show</SPAN><SPAN class="punctuation token">(</SPAN>$<SPAN class="string token">"Polyline feature layer {item.Key.Name} selected"</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>
Thanks
Uma
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.