private async void LoadLayers_Clicked(object sender, RoutedEventArgs e) { // Skip if nothing selected. if (OgcFeatureCollectionList.SelectedItems.Count < 1) { return; } // Show the progress bar. LoadingProgressBar.Visibility = Visibility.Visible; // Clear the existing layers. MyMapView.Map.OperationalLayers.Clear(); try { // Get the selected collection. OgcFeatureCollectionInfo selectedCollectionInfo = (OgcFeatureCollectionInfo)OgcFeatureCollectionList.SelectedItems[0]; // Create the OGC feature collection table. OgcFeatureCollectionTable table = new OgcFeatureCollectionTable(selectedCollectionInfo); // Set the feature request mode to manual (only manual is currently supported). // In this mode, you must manually populate the table - panning and zooming won't request features automatically. table.FeatureRequestMode = FeatureRequestMode.ManualCache; // Populate the OGC feature collection table. QueryParameters queryParamaters = new QueryParameters(); queryParamaters.MaxFeatures = 1000; await table.PopulateFromServiceAsync(queryParamaters, false, null); // Create a feature layer from the OGC feature collection table. FeatureLayer ogcFeatureLayer = new FeatureLayer(table); // Choose a renderer for the layer based on the table. ogcFeatureLayer.Renderer = GetRendererForTable(table) ?? ogcFeatureLayer.Renderer; // Add the layer to the map. MyMapView.Map.OperationalLayers.Add(ogcFeatureLayer); // Zoom to the extent of the selected collection. if (selectedCollectionInfo.Extent is Envelope collectionExtent && !collectionExtent.IsEmpty) { await MyMapView.SetViewpointGeometryAsync(collectionExtent, 100); } } catch (Exception ex) { Debug.WriteLine(ex); await new MessageDialog(ex.Message, "Error loading service").ShowAsync(); } finally { // Hide the progress bar. LoadingProgressBar.Visibility = Visibility.Collapsed; } }
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 collection. OgcFeatureCollectionInfo selectedCollectionInfo = _serviceInfo.FeatureCollectionInfos[e.Item.Order]; // Create the OGC feature collection table. OgcFeatureCollectionTable table = new OgcFeatureCollectionTable(selectedCollectionInfo); // Set the feature request mode to manual (only manual is currently supported). // In this mode, you must manually populate the table - panning and zooming won't request features automatically. table.FeatureRequestMode = FeatureRequestMode.ManualCache; // Populate the OGC feature collection table. QueryParameters queryParamaters = new QueryParameters(); queryParamaters.MaxFeatures = 1000; await table.PopulateFromServiceAsync(queryParamaters, false, null); // Create a feature layer from the OGC feature collection table. FeatureLayer ogcFeatureLayer = new FeatureLayer(table); // Choose a renderer for the layer based on the table. ogcFeatureLayer.Renderer = GetRendererForTable(table) ?? ogcFeatureLayer.Renderer; // Add the layer to the map. _myMapView.Map.OperationalLayers.Add(ogcFeatureLayer); // Zoom to the extent of the selected collection. if (selectedCollectionInfo.Extent is Envelope collectionExtent && !collectionExtent.IsEmpty) { await _myMapView.SetViewpointGeometryAsync(collectionExtent, 100); } } 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(OgcFeatureCollectionInfo selectedLayerInfo) { // Show the progress bar. _loadingProgressBar.StartAnimating(); // Clear the existing layers. _myMapView.Map.OperationalLayers.Clear(); try { // Create the OGC feature collection table. OgcFeatureCollectionTable table = new OgcFeatureCollectionTable(selectedLayerInfo); // Set the feature request mode to manual (only manual is currently supported). // In this mode, you must manually populate the table - panning and zooming won't request features automatically. table.FeatureRequestMode = FeatureRequestMode.ManualCache; // Populate the OGC feature collection table. QueryParameters queryParamaters = new QueryParameters(); queryParamaters.MaxFeatures = 1000; await table.PopulateFromServiceAsync(queryParamaters, false, null); // Create a feature layer from the OGC feature collection table. FeatureLayer ogcFeatureLayer = new FeatureLayer(table); // Choose a renderer for the layer based on the table. ogcFeatureLayer.Renderer = GetRendererForTable(table) ?? ogcFeatureLayer.Renderer; // Add the layer to the map. _myMapView.Map.OperationalLayers.Add(ogcFeatureLayer); // Zoom to the extent of the selected collection. if (selectedLayerInfo.Extent is Envelope collectionExtent && !collectionExtent.IsEmpty) { await _myMapView.SetViewpointGeometryAsync(collectionExtent, 100); } } catch (Exception ex) { Debug.WriteLine(ex); new UIAlertView("Couldn't load layer.", ex.Message, (IUIAlertViewDelegate)null, "OK", null).Show(); } finally { // Hide the progress bar. _loadingProgressBar.StopAnimating(); } }