private async void BtnZoomToFeatures_Click(object sender, EventArgs e) { // Create the query parameters QueryParameters queryStates = new QueryParameters { WhereClause = $"upper(ST) LIKE '%{txtStateEntry.Text.ToUpper()}%'" }; // Get the extent from the query Envelope resultExtent = await _myFeatureTable.QueryExtentAsync(queryStates); // Return if there is no result (might happen if query is invalid) if (resultExtent?.SpatialReference == null) { return; } // Create a viewpoint from the extent Viewpoint resultViewpoint = new Viewpoint(resultExtent); // Zoom to the viewpoint await MyMapView.SetViewpointAsync(resultViewpoint); // Update the UI txtResults.Text = $"Zoomed to features in {txtStateEntry.Text}"; }
private async void BtnZoomToFeaturesClick(object sender, RoutedEventArgs e) { try { // Create the query parameters. QueryParameters queryStates = new QueryParameters { WhereClause = $"upper(State) LIKE '%{StateTextbox.Text}%'" }; // Get the extent from the query. Envelope resultExtent = await _featureTable.QueryExtentAsync(queryStates); // Return if there is no result (might happen if query is invalid). if (resultExtent?.SpatialReference == null) { ResultsTextbox.Text = "No results. Search for an abbreviated name (e.g. NH)."; return; } // Create a viewpoint from the extent. Viewpoint resultViewpoint = new Viewpoint(resultExtent); // Zoom to the viewpoint. await MyMapView.SetViewpointAsync(resultViewpoint); // Update the UI. ResultsTextbox.Text = $"Zoomed to features in {StateTextbox.Text}"; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error"); } }
private async void BtnZoomToFeatures_Click(object sender, EventArgs e) { // Create the query parameters. QueryParameters queryStates = new QueryParameters { WhereClause = $"upper(State) LIKE '%{_myStateEntry.Text.ToUpper()}%'" }; try { // Get the extent from the query. Envelope resultExtent = await _featureTable.QueryExtentAsync(queryStates); // Return if there is no result (might happen if query is invalid). if (resultExtent?.SpatialReference == null) { _myResultsLabel.Text = $"Couldn't zoom to features in {_myStateEntry.Text}."; return; } // Create a viewpoint from the extent. Viewpoint resultViewpoint = new Viewpoint(resultExtent); // Zoom to the viewpoint. await _myMapView.SetViewpointAsync(resultViewpoint); // Update label. _myResultsLabel.Text = $"Zoomed to features in {_myStateEntry.Text}."; } catch (Exception ex) { new AlertDialog.Builder(this).SetMessage(ex.ToString()).SetTitle("Error").Show(); } }
private async void ZoomToFeature(string query) { // Create the query parameters. QueryParameters queryStates = new QueryParameters { WhereClause = $"upper(State) LIKE '%{query.ToUpper()}%'" }; try { // Get the extent from the query. Envelope resultExtent = await _featureTable.QueryExtentAsync(queryStates); // Return if there is no result (might happen if query is invalid). if (resultExtent?.SpatialReference == null) { return; } // Create a viewpoint from the extent. Viewpoint resultViewpoint = new Viewpoint(resultExtent); // Zoom to the viewpoint. await _myMapView.SetViewpointAsync(resultViewpoint); // Update the UI. _resultLabel.Text = $"Zoomed to features in {query}"; } catch (Exception ex) { new UIAlertView("Error", ex.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
private async void BtnZoomToFeaturesClick(object sender, RoutedEventArgs e) { // Create the query parameters. QueryParameters queryStates = new QueryParameters() { WhereClause = $"upper(State) LIKE '%{StateEntry.Text.ToUpper()}%'" }; try { // Get the extent from the query. Envelope resultExtent = await _featureTable.QueryExtentAsync(queryStates); // Return if there is no result (might happen if query is invalid). if (resultExtent?.SpatialReference == null) { return; } // Create a viewpoint from the extent. Viewpoint resultViewpoint = new Viewpoint(resultExtent); // Zoom to the viewpoint. await MyMapView.SetViewpointAsync(resultViewpoint); // Update the UI. ResultView.Text = $"Zoomed to features in {StateEntry.Text}"; ResultView.Visibility = Visibility.Visible; } catch (Exception ex) { await new MessageDialog(ex.ToString(), "Error").ShowAsync(); } }
private async void BtnZoomToFeaturesClick(object sender, RoutedEventArgs e) { // Create the query parameters. QueryParameters queryStates = new QueryParameters() { WhereClause = string.Format("upper(ST) LIKE '%{0}%'", StateTextbox.Text.ToUpper()) }; // Get the extent from the query. Envelope resultExtent = await _myFeatureTable.QueryExtentAsync(queryStates); // Return if there is no result (might happen if query is invalid). if (resultExtent == null || resultExtent.SpatialReference == null) { ResultsTextbox.Text = "No results. Search for an abbreviated name (e.g. NH)."; return; } // Create a viewpoint from the extent. Viewpoint resultViewpoint = new Viewpoint(resultExtent); // Zoom to the viewpoint. await MyMapView.SetViewpointAsync(resultViewpoint); // Update the UI. ResultsTextbox.Text = string.Format("Zoomed to features in {0}", StateTextbox.Text); }
private async void BtnZoomToFeatures_Click(object sender, EventArgs e) { // Create the query parameters. QueryParameters queryStates = new QueryParameters { WhereClause = $"upper(State) LIKE '%{txtStateEntry.Text.ToUpper()}%'" }; try { // Get the extent from the query. Envelope resultExtent = await _featureTable.QueryExtentAsync(queryStates); // Return if there is no result (might happen if query is invalid). if (resultExtent?.SpatialReference == null) { return; } // Create a viewpoint from the extent. Viewpoint resultViewpoint = new Viewpoint(resultExtent); // Zoom to the viewpoint. await MyMapView.SetViewpointAsync(resultViewpoint); // Update the UI. txtResults.Text = $"Zoomed to features in {txtStateEntry.Text}"; } catch (Exception ex) { await((Page)Parent).DisplayAlert("Error", ex.ToString(), "OK"); } }