private async void LoadLayers_Clicked(object sender, EventArgs e) { // Show the progress bar. LoadingProgressBar.IsVisible = true; // Clear the existing layers. MyMapView.Map.OperationalLayers.Clear(); try { // Add the layer to the map. WfsLayerInfo selectedLayerInfo = (WfsLayerInfo)WfsLayerList.SelectedItem; // Create the WFS feature table. WfsFeatureTable table = new WfsFeatureTable(selectedLayerInfo); // Set the feature request mode to manual - only manual is supported at v100.5. // In this mode, you must manually populate the table - panning and zooming won't request features automatically. table.FeatureRequestMode = FeatureRequestMode.ManualCache; // Set the axis order based on the UI. if (AxisOrderSwapCheckbox.IsToggled) { table.AxisOrder = OgcAxisOrder.Swap; } else { table.AxisOrder = OgcAxisOrder.NoSwap; } // Populate the WFS table. await table.PopulateFromServiceAsync(new QueryParameters(), false, null); // Create a feature layer from the WFS table. FeatureLayer wfsFeatureLayer = new FeatureLayer(table); // Choose a renderer for the layer based on the table. wfsFeatureLayer.Renderer = GetRandomRendererForTable(table) ?? wfsFeatureLayer.Renderer; // Add the layer to the map. MyMapView.Map.OperationalLayers.Add(wfsFeatureLayer); // Zoom to the extent of the layer. await MyMapView.SetViewpointGeometryAsync(selectedLayerInfo.Extent, 50); } catch (Exception exception) { Debug.WriteLine(exception); await((Page)Parent).DisplayAlert("Failed to load layer", exception.ToString(), "OK"); } finally { // Hide the progress bar. LoadingProgressBar.IsVisible = false; } }
private async void LayerMenu_LayerSelected(object sender, PopupMenu.MenuItemClickEventArgs e) { // Show the progress bar. _loadingProgressBar.Visibility = ViewStates.Visible; // Clear the existing layers. _myMapView.Map.OperationalLayers.Clear(); try { // Get the selected layer info. WfsLayerInfo selectedLayerInfo = _serviceInfo.LayerInfos[e.Item.Order]; // Create the WFS feature table. WfsFeatureTable table = new WfsFeatureTable(selectedLayerInfo); // Set the feature request mode to manual - only manual is supported at v100.5. // In this mode, you must manually populate the table - panning and zooming won't request features automatically. table.FeatureRequestMode = FeatureRequestMode.ManualCache; // Set the axis order based on the UI. if (_axisOrderSwitch.Checked) { table.AxisOrder = OgcAxisOrder.Swap; } else { table.AxisOrder = OgcAxisOrder.NoSwap; } // Populate the WFS table. await table.PopulateFromServiceAsync(new QueryParameters(), false, null); // Create a feature layer from the WFS table. FeatureLayer wfsFeatureLayer = new FeatureLayer(table); // Choose a renderer for the layer based on the table. wfsFeatureLayer.Renderer = GetRendererForTable(table) ?? wfsFeatureLayer.Renderer; // Add the layer to the map. _myMapView.Map.OperationalLayers.Add(wfsFeatureLayer); // Zoom to the extent of the layer. await _myMapView.SetViewpointGeometryAsync(selectedLayerInfo.Extent, 50); } catch (Exception exception) { System.Diagnostics.Debug.WriteLine(exception); new AlertDialog.Builder(this).SetMessage(exception.ToString()).SetTitle("Couldn't load layer.").Show(); } finally { // Hide the progress bar. _loadingProgressBar.Visibility = ViewStates.Gone; } }
private async void LoadSelectedLayer(WfsLayerInfo selectedLayerInfo) { // Show the progress bar. _loadingProgressBar.StartAnimating(); // Clear the existing layers. _myMapView.Map.OperationalLayers.Clear(); try { // Create the WFS feature table. WfsFeatureTable table = new WfsFeatureTable(selectedLayerInfo); // Set the feature request mode to manual - only manual is supported at v100.5. // In this mode, you must manually populate the table - panning and zooming won't request features automatically. table.FeatureRequestMode = FeatureRequestMode.ManualCache; // Set the axis order based on the UI. if (_toggleAxisOrderSwitch.On) { table.AxisOrder = OgcAxisOrder.Swap; } else { table.AxisOrder = OgcAxisOrder.NoSwap; } // Populate the WFS table. await table.PopulateFromServiceAsync(new QueryParameters(), false, null); // Create a feature layer from the WFS table. FeatureLayer wfsFeatureLayer = new FeatureLayer(table); // Choose a renderer for the layer based on the table. wfsFeatureLayer.Renderer = GetRandomRendererForTable(table) ?? wfsFeatureLayer.Renderer; // Add the layer to the map. _myMapView.Map.OperationalLayers.Add(wfsFeatureLayer); // Zoom to the extent of the layer. await _myMapView.SetViewpointGeometryAsync(selectedLayerInfo.Extent, 50); } catch (Exception exception) { Debug.WriteLine(exception); new UIAlertView("Error", exception.ToString(), (IUIAlertViewDelegate)null, "Couldn't load layer.", null).Show(); } finally { // Hide the progress bar. _loadingProgressBar.StopAnimating(); } }
private async void LoadLayers_Clicked(object sender, RoutedEventArgs e) { // Skip if nothing selected. if (WfsLayerList.SelectedItems.Count < 1) { return; } // Show the progress bar. LoadingProgressBar.Visibility = Visibility.Visible; // Clear the existing layers. MyMapView.Map.OperationalLayers.Clear(); try { // Get the selected WFS layer. WfsLayerInfo selectedLayerInfo = (WfsLayerInfo)WfsLayerList.SelectedItems[0]; // Create the WFS feature table. WfsFeatureTable table = new WfsFeatureTable(selectedLayerInfo); // Set the feature request mode to manual - only manual is supported at v100.5. // In this mode, you must manually populate the table - panning and zooming won't request features automatically. table.FeatureRequestMode = FeatureRequestMode.ManualCache; // Set the axis order based on the UI. if (AxisOrderSwapCheckbox.IsChecked == true) { table.AxisOrder = OgcAxisOrder.Swap; } else { table.AxisOrder = OgcAxisOrder.NoSwap; } // Populate the WFS table. await table.PopulateFromServiceAsync(new QueryParameters(), false, null); // Create a feature layer from the WFS table. FeatureLayer wfsFeatureLayer = new FeatureLayer(table); // Choose a renderer for the layer based on the table. wfsFeatureLayer.Renderer = GetRendererForTable(table) ?? wfsFeatureLayer.Renderer; // Add the layer to the map. MyMapView.Map.OperationalLayers.Add(wfsFeatureLayer); // Zoom to the extent of the selected layer. await MyMapView.SetViewpointGeometryAsync(selectedLayerInfo.Extent, 50); } catch (Exception ex) { Debug.WriteLine(ex); await new MessageDialog(ex.ToString(), "Failed to load layer.").ShowAsync(); } finally { // Hide the progress bar. LoadingProgressBar.Visibility = Visibility.Collapsed; } }