All,
1/ I do query and zoom to selection in layout view.
2/ If I have only 1 map frame, the below codes work just fine.
3/ When I added a another map frame for locator map, I got the error "layer does not exist". I guess I have to specify which map it should use but I don't know how. Thanks for your help.
<SPAN class="keyword token">var</SPAN> myLyr <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">FindLayers</SPAN><SPAN class="punctuation token">(</SPAN>featureLayerName<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="keyword token">as</SPAN> FeatureLayer<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>myLyr <SPAN class="operator token">==</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">throw</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Exception</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">string</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">Format</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"The feature class: {0} does not exist"</SPAN><SPAN class="punctuation token">,</SPAN> featureLayerName<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>