private async void Initialize() { // Create the map with basemap. _myMapView.Map = new Map(Basemap.CreateNavigationVector()); try { // Create the WFS feature table from URL and name. WfsFeatureTable wfsTable = new WfsFeatureTable(new Uri(TableUrl), LayerName); // Set the feature request mode to manual. Only calls to PopulateFromService will load features. // Features will not be populated automatically when the user pans and zooms the layer. wfsTable.FeatureRequestMode = FeatureRequestMode.ManualCache; // Load the WFS feature table. await wfsTable.LoadAsync(); // Create a feature layer to visualize the WFS feature table. FeatureLayer statesLayer = new FeatureLayer(wfsTable); // Add the layer to the map. _myMapView.Map.OperationalLayers.Add(statesLayer); // Populate the WFS feature table with the XML query. await wfsTable.PopulateFromServiceAsync(XmlQuery, true); // Zoom to the extent of the query results. await _myMapView.SetViewpointGeometryAsync(wfsTable.Extent, 50); } catch (Exception e) { Debug.WriteLine(e.ToString()); new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "Couldn't populate table with XML query.", null).Show(); } }
private async void MapView_NavigationCompleted(object sender, EventArgs e) { // Show the loading bar. LoadingProgressBar.Visibility = Visibility.Visible; // Get the current extent. Envelope currentExtent = MyMapView.VisibleArea.Extent; // Create a query based on the current visible extent. QueryParameters visibleExtentQuery = new QueryParameters(); visibleExtentQuery.Geometry = currentExtent; visibleExtentQuery.SpatialRelationship = SpatialRelationship.Intersects; try { // Populate the table with the query, leaving existing table entries intact. // Setting outFields to null requests all features. await _featureTable.PopulateFromServiceAsync(visibleExtentQuery, false, null); } catch (Exception exception) { await new MessageDialog(exception.ToString(), "Couldn't populate table.").ShowAsync(); Debug.WriteLine(exception); } finally { // Hide the loading bar. LoadingProgressBar.Visibility = Visibility.Collapsed; } }
private async void UpdateForExtent() { // Show the loading bar. _loadingProgressBar.StartAnimating(); // Get the current extent. Envelope currentExtent = _myMapView.VisibleArea.Extent; // Create a query based on the current visible extent. QueryParameters visibleExtentQuery = new QueryParameters(); visibleExtentQuery.Geometry = currentExtent; visibleExtentQuery.SpatialRelationship = SpatialRelationship.Intersects; try { // Populate the table with the query, leaving existing table entries intact. // Setting outFields to null requests all features. await _featureTable.PopulateFromServiceAsync(visibleExtentQuery, false, null); } catch (Exception exception) { new UIAlertView("Couldn't populate table", exception.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); Debug.WriteLine(exception); } finally { // Hide the loading bar. _loadingProgressBar.StopAnimating(); } }
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; } }