/// <summary> /// Takes action once a new content selection is made. /// </summary> public void ContentSelectionChanged(int selectedIndex) { // Get the KML node. LayerDisplayVM selectedItem = _viewModelList[selectedIndex]; NavigateToNode(selectedItem.Node); }
private void MyDisplayList_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { // Get the KML node. LayerDisplayVM selectedItem = _viewModelList[e.Position]; NavigateToNode(selectedItem.Node); }
public static void BuildLayerInfoList(LayerDisplayVM root, IList <LayerDisplayVM> result) { // Add the root node to the result list. result.Add(root); // Make the node visible. root.Node.IsVisible = true; // Recursively add children. KmlContainers and KmlNetworkLinks can both have children. var containerNode = root.Node as KmlContainer; var networkLinkNode = root.Node as KmlNetworkLink; List <KmlNode> children = new List <KmlNode>(); if (containerNode != null) { children.AddRange(containerNode.ChildNodes); } if (networkLinkNode != null) { children.AddRange(networkLinkNode.ChildNodes); } foreach (KmlNode node in children) { // Create the view model for the sublayer. LayerDisplayVM layerVM = new LayerDisplayVM(node, root); // Recursively add children. BuildLayerInfoList(layerVM, result); } }
private void LayerTreeView_OnSelectionChanged(object sender, SelectedItemChangedEventArgs e) { // Get the KML node. LayerDisplayVM selectedItem = (LayerDisplayVM)e.SelectedItem; NavigateToNode(selectedItem.Node); }
private async void Initialize() { // Add a basemap. MySceneView.Scene = new Scene(Basemap.CreateImageryWithLabels()); MySceneView.Scene.BaseSurface.ElevationSources.Add(new ArcGISTiledElevationSource(new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"))); // Get the URL to the data. Uri kmlUrl = new Uri(DataManager.GetDataFolder("da301cb122874d5497f8a8f6c81eb36e", "esri_test_data.kmz")); // Create the KML dataset and layer. KmlDataset dataset = new KmlDataset(kmlUrl); KmlLayer layer = new KmlLayer(dataset); // Add the layer to the map. MySceneView.Scene.OperationalLayers.Add(layer); await dataset.LoadAsync(); // Build the ViewModel from the expanded list of layer infos. foreach (KmlNode node in dataset.RootNodes) { // LayerDisplayVM is a custom type made for this sample to serve as the ViewModel; it is not a part of ArcGIS Runtime. LayerDisplayVM nodeVm = new LayerDisplayVM(node, null); _viewModelList.Add(nodeVm); LayerDisplayVM.BuildLayerInfoList(nodeVm, _viewModelList); } // Update the list of layers, using the root node from the list. LayerTreeView.ItemsSource = _viewModelList; }
private async void Initialize() { // Add a basemap. _mySceneView.Scene = new Scene(Basemap.CreateImageryWithLabels()); _mySceneView.Scene.BaseSurface.ElevationSources.Add(new ArcGISTiledElevationSource(new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"))); // Get the URL to the data. Uri kmlUrl = new Uri(DataManager.GetDataFolder("da301cb122874d5497f8a8f6c81eb36e", "esri_test_data.kmz")); // Create the KML dataset and layer. KmlDataset dataset = new KmlDataset(kmlUrl); KmlLayer layer = new KmlLayer(dataset); // Add the layer to the map. _mySceneView.Scene.OperationalLayers.Add(layer); try { await dataset.LoadAsync(); // Build the ViewModel from the expanded list of layer infos. foreach (KmlNode node in dataset.RootNodes) { // LayerDisplayVM is a custom type made for this sample to serve as the ViewModel; it is not a part of ArcGIS Runtime. LayerDisplayVM nodeVm = new LayerDisplayVM(node, null); _viewModelList.Add(nodeVm); LayerDisplayVM.BuildLayerInfoList(nodeVm, _viewModelList); } // Create an array adapter for the content display ArrayAdapter adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, _viewModelList.Select(item => item.Name).ToList()); // Apply the adapter _myDisplayList.Adapter = adapter; // Subscribe to selection change notifications _myDisplayList.ItemClick += MyDisplayList_ItemClick; } catch (Exception e) { new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show(); } }
private async void Initialize() { // Add a basemap. _mySceneView.Scene = new Scene(Basemap.CreateImageryWithLabels()); _mySceneView.Scene.BaseSurface.ElevationSources.Add(new ArcGISTiledElevationSource(new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"))); // Get the URL to the data. Uri kmlUrl = new Uri(DataManager.GetDataFolder("da301cb122874d5497f8a8f6c81eb36e", "esri_test_data.kmz")); // Create the KML dataset and layer. KmlDataset dataset = new KmlDataset(kmlUrl); KmlLayer layer = new KmlLayer(dataset); // Add the layer to the map. _mySceneView.Scene.OperationalLayers.Add(layer); try { await dataset.LoadAsync(); // Build the ViewModel from the expanded list of layer infos. foreach (KmlNode node in dataset.RootNodes) { // LayerDisplayVM is a custom type made for this sample to serve as the ViewModel; it is not a part of ArcGIS Runtime. LayerDisplayVM nodeVm = new LayerDisplayVM(node, null); _viewModelList.Add(nodeVm); LayerDisplayVM.BuildLayerInfoList(nodeVm, _viewModelList); } // Construct the layer list source. _layerListSource = new LayerListSource(_viewModelList, this); // Set the source for the table view (layer list). _myDisplayList.Source = _layerListSource; // Force an update of the list display. _myDisplayList.ReloadData(); } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
/// <summary> /// This method gets a table view cell for the suggestion at the specified index. /// </summary> public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { // Try to get a re-usable cell (this is for performance). UITableViewCell cell = tableView.DequeueReusableCell(CellId); // If there are no cells, create a new one. if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Default, CellId) { BackgroundColor = UIColor.FromWhiteAlpha(0, 0f) }; cell.TextLabel.TextColor = Owner.View.TintColor; } // Get the specific item to display. LayerDisplayVM item = ViewModelList[indexPath.Row]; // Set the text on the cell. cell.TextLabel.Text = item.Name; // Return the cell. return(cell); }
public LayerDisplayVM(KmlNode info, LayerDisplayVM parent) { Node = info; Parent = parent; }