private void ButtonIdentify_Click(object sender, RoutedEventArgs e) { MyDrawObject.IsEnabled = false; if (IdentifyButtonClicked == false) { // Make IdentifyStackPAnel visible IdentifyButtonClicked = true; IdentifyStackPanel.Visibility = Visibility.Visible; } else { // Make IdentifyStackPanel not visibile, clear identify graphic, clear IdentifyComboBox & collapse IdentifyButtonClicked = false; IdentifyStackPanel.Visibility = Visibility.Collapsed; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); IdentifyComboBox.Items.Clear(); IdentifyComboBox.UpdateLayout(); IdentifyResultsPanel.Visibility = Visibility.Collapsed; MyMap.Cursor = Cursors.Arrow; } }
private void QueryPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e) { // create identifyParams object IdentifyParameters identifyParams = new IdentifyParameters() { Geometry = mapPoint, //Tolerance = 50, MapExtent = mainPage.map.Extent, Width = (int)mainPage.map.ActualWidth, Height = (int)mainPage.map.ActualHeight, LayerOption = LayerOption.visible, SpatialReference = mainPage.map.SpatialReference }; // store all the available services in to myMapService stack storeMapServices(); identifyTask.Url = myMapService.Pop(); identifyTask.ExecuteAsync(identifyParams, identifyParams); }
void identifyTask_ExecuteCompleted(object sender, IdentifyEventArgs e) { if (e.IdentifyResults != null && e.IdentifyResults.Count > 0) { boolNeedReset = false; //get Layerkeyfield and add identify results to dictionary ShowFeatures(e.IdentifyResults); } if (tempInt < 2) { identifyTask.Url = myMapService.Pop(); IdentifyParameters identifyParams = e.UserState as IdentifyParameters; identifyTask.ExecuteAsync(identifyParams, identifyParams); } }
public void ShowFeatures(List<IdentifyResult> results) { int intFeatureCount = 0; //Get the Layer Key Field DataAccessService.DataAccessServiceClient dataAccessServiceClient = new DataAccessService.DataAccessServiceClient(); dataAccessServiceClient.getLayerKeyIDAsync(results[0].LayerName); dataAccessServiceClient.getLayerKeyIDCompleted += ((s, e) => { if (e.Result != string.Empty && e.Result != null) { kvpLayerKeyField.Add(results[0].LayerName, e.Result); foreach (IdentifyResult result in results) { if (!kvpIdentifyResults.Keys.Contains(Convert.ToInt32(results[intFeatureCount].Feature.Attributes[e.Result]))) { kvpIdentifyResults.Add(Convert.ToInt32(results[intFeatureCount].Feature.Attributes[e.Result]), results[intFeatureCount].LayerName); intFeatureCount++; } } //add identified layernames to combobox IdentifyComboBox.Items.Add(results[0].LayerName); } }); }
namespace SilverlightApplication1 { public partial class MainPage : UserControl { // Used by Identify private List<DataItem> _dataItems = null; bool IdentifyButtonClicked = false; private bool _needReset = true; //*** bool IdentifyResultsPanelVisible = false; private IdentifyTask identifyTask = new IdentifyTask(); public Stack<string> myMapService = new Stack<string>(); ...
public MainPage() { InitializeComponent(); identifyTask.ExecuteCompleted +=new EventHandler<IdentifyEventArgs>(identifyTask_ExecuteCompleted); identifyTask.Failed +=new EventHandler<TaskFailedEventArgs>(identifyTask_Failed); UpdateMapServices(); //** This finds all dynamic map services I am using }
//** Used by Identify private void UpdateMapServices() { Stack<string> myTempStack = new Stack<string>(); foreach (Layer layer in MyMap.Layers) { ArcGISDynamicMapServiceLayer dynamicLayer = layer as ArcGISDynamicMapServiceLayer; if (dynamicLayer != null) { myTempStack.Push(dynamicLayer.Url.ToString()); } } // Reverse stack order to reflect layers as drawn while (myTempStack.Count != 0) { myMapService.Push(myTempStack.Pop().ToString()); } }
private void QueryPoint_MouseClick(object sender, Map.MouseEventArgs e) { if (IdentifyButtonClicked == true) //*** Used by my IdentifyButton { if (IdentifyResultsPanelVisible) { IdentifyResultsPanel.Visibility = Visibility.Collapsed; } MapPoint clickPoint = e.MapPoint; IdentifyParameters identifyParams = new IdentifyParameters() { Geometry = clickPoint, Tolerance = 20, MapExtent = MyMap.Extent, Width = (int)MyMap.ActualWidth, Height = (int)MyMap.ActualHeight, LayerOption = LayerOption.all, SpatialReference = MyMap.SpatialReference }; identifyTask.Url = myMapService.Pop(); identifyTask.ExecuteAsync(identifyParams, identifyParams); MyMap.Cursor = Cursors.Wait; // _needReset is a flag used to determine if the user clicks on the map to a new identify _needReset = true; //*** if (_needReset) //*** { GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = clickPoint, Symbol = MapRow.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol }; graphicsLayer.Graphics.Add(graphic); } } }
public void ShowFeature(List<IdentifyResult> results) { // if true new identify is being requested, need to setup new list and clear identifyCombobox if (_needReset) { _dataItems = new List<DataItem>(); IdentifyComboBox.Items.Clear(); //*** _needReset = false; } if (results != null && results.Count > 0) { foreach (IdentifyResult result in results) { Graphic feature = result.Feature; string tempLayerName = "(" + result.LayerName + ")"; string title = tempLayerName.PadRight(20, ' ') +"|" + result.Value.ToString();// formatting _dataItems.Add(new DataItem() { Title = title, Data = feature.Attributes }); IdentifyComboBox.Items.Add(title); } IdentifyComboBox.SelectedIndex = 0; } }
void identifyTask_ExecuteCompleted(object sender, IdentifyEventArgs e) { if (_needReset) //If this is a new identify request then { IdentifyDetailDataGrid.ItemsSource = null; // clear datagrid } if (e.IdentifyResults != null && e.IdentifyResults.Count > 0) { ShowFeature(e.IdentifyResults); } else { IdentifyComboBox.Items.Clear(); IdentifyComboBox.UpdateLayout(); IdentifyResultsPanel.Visibility = Visibility.Collapsed; IdentifyResultsPanelVisible = false; } if (myMapService.Count == 0) // once all map services had been identify then: { UpdateMapServices(); // re-populate the stack MyMap.Cursor = Cursors.Stylus; // set stylus IdentifyResultsPanel.Visibility = Visibility.Visible; // show result panel IdentifyResultsPanelVisible = true; // set flag to true } else { identifyTask.Url = myMapService.Pop(); // get next dynamicMapService url for identify IdentifyParameters identifyParams = e.UserState as IdentifyParameters; // pass in userstate identifyTask.ExecuteAsync(identifyParams, identifyParams); // execute } }
<!--Identify--> <StackPanel x:Name="IdentifyStackPanel" Orientation="Vertical"> <Border x:Name="IdentifyBorder" Background="#77919191" BorderThickness="1" CornerRadius="5" HorizontalAlignment="Left" BorderBrush="Gray" VerticalAlignment="Top" Margin="5"> <Border.Effect> <DropShadowEffect/> </Border.Effect> <Grid x:Name="IdentifyGrid" HorizontalAlignment="Right" VerticalAlignment="Top" > <Grid.RowDefinitions> <RowDefinition Height="30" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <TextBlock x:Name="DataDisplayTitleBottom" Text="Click on map to Identify a feature" Foreground="White" FontSize="10" Grid.Row="0" Margin="15,5,15,1" HorizontalAlignment="Center" > <TextBlock.Effect> <DropShadowEffect /> </TextBlock.Effect> </TextBlock> <Grid x:Name="IdentifyResultsPanel" Margin="5,1,5,5" HorizontalAlignment="Center" VerticalAlignment="Top" Visibility="Collapsed" Grid.Row="1"> <Grid.RowDefinitions> <RowDefinition Height="30" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <ComboBox x:Name="IdentifyComboBox" SelectionChanged="cb_SelectionChanged" Margin="5,1,5,5" Grid.Row="0" FontFamily="Consolas" FontSize="12" Foreground="Brown"> </ComboBox> <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Width="330" MinHeight="200" Grid.Row="1"> <slData:DataGrid x:Name="IdentifyDetailDataGrid" AutoGenerateColumns="False" HeadersVisibility="None" Background="White"> <slData:DataGrid.Columns> <!--Shows field names*****--> <slData:DataGridTextColumn Binding="{Binding Path=Key}" FontWeight="Bold"/> <!--Shows field values*****--> <slData:DataGridTextColumn Binding="{Binding Path=Value}" /> </slData:DataGrid.Columns> </slData:DataGrid> </ScrollViewer> </Grid> </Grid> </Border> </StackPanel>
identifyTask = new IdentifyTask(); identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted; identifyTask.Failed += IdentifyTask_Failed; mapServices = new Stack<string>(); UpdateMapServices(); //TODO: push or enqueue map service URL's
identifyTask.Url = mapServices.Pop(); identifyTask.ExecuteAsync(identifyParams, identifyParams);
if (mapServices.Count == 0) UpdateMapServices(); //to re-add the map services for the next click event else { identifyTask.Url = mapServices.Pop(); IdentifyParameters identifyParams = args.UserState as IdentifyParameters; identifyTask.ExecuteAsync(identifyParams, identifyParams ); }
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.