private async void MapView_Tapped(object sender, GeoViewInputEventArgs e)
        {
            // Clear any existing selection.
            _damageLayer.ClearSelection();

            // Dismiss any existing callouts.
            _myMapView.DismissCallout();

            try
            {
                // Perform an identify to determine if a user tapped on a feature.
                IdentifyLayerResult identifyResult = await _myMapView.IdentifyLayerAsync(_damageLayer, e.Position, 8, false);

                // Do nothing if there are no results.
                if (!identifyResult.GeoElements.Any())
                {
                    return;
                }

                // Get the tapped feature.
                _selectedFeature = (ArcGISFeature)identifyResult.GeoElements.First();

                // Select the feature.
                _damageLayer.SelectFeature(_selectedFeature);

                // Update the UI for the selection.
                ShowFeatureOptions();
            }
            catch (Exception ex)
            {
                ShowMessage("Error selecting feature.", ex.ToString());
            }
        }
예제 #2
0
        /// <summary>
        /// 物件リストボックスの選択変更時の処理
        /// </summary>
        private void selectedBuildingListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //物件リストボックスで新規選択が行われていなければ処理を行わない
            if (e.AddedItems.Count < 1)
            {
                return;
            }

            //物件レイヤのフィーチャの選択をすべてクリア
            buildingLayer.ClearSelection();

            try
            {
                //物件リストボックスで選択された最初の物件フィーチャを物件フィーチャレイヤ上で選択
                Feature selectedFeature = e.AddedItems[0] as Feature;
                buildingLayer.SelectFeatures(new long[] { Convert.ToInt64(selectedFeature.Attributes[buildingLayer.FeatureTable.ObjectIDField]) });

                //選択されたフィーチャを中心に地図を移動
                mainMapView.SetView((MapPoint)selectedFeature.Geometry);
            }
            //エラーが発生した場合の処理
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("物件フィーチャの選択:{0}", ex.Message));
            }
        }
        private async void MyMapView_MapViewTapped(object sender, Esri.ArcGISRuntime.Controls.MapViewInputEventArgs e)
        {
            try
            {
                if (MyDataForm.ResetCommand.CanExecute(null))
                {
                    MyDataForm.ResetCommand.Execute(null);
                }

                MyDataForm.GeodatabaseFeature = null;

                if (_editedLayer != null)
                {
                    _editedLayer.ClearSelection();
                }

                foreach (var layer in MyMapView.Map.Layers.OfType <FeatureLayer>().Reverse())
                {
                    // Get possible features and if none found, move to next layer
                    var foundFeatures = await layer.HitTestAsync(MyMapView, new Rect(e.Position, new Size(10, 10)), 1);

                    if (foundFeatures.Count() == 0)
                    {
                        continue;
                    }

                    // Get feature from table
                    var feature = await layer.FeatureTable.QueryAsync(foundFeatures[0]);

                    // Change UI
                    DescriptionTextArea.Visibility = Visibility.Collapsed;
                    DataFormArea.Visibility        = Visibility.Visible;

                    _editedFeature = feature as GeodatabaseFeature;
                    _editedLayer   = layer;
                    _editedLayer.SelectFeatures(new long[] { foundFeatures[0] });

                    // Set feature that is being edited to data form
                    MyDataForm.GeodatabaseFeature = _editedFeature;
                    return;
                }

                // No features found
                DescriptionTextArea.Visibility = Visibility.Visible;
                DataFormArea.Visibility        = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Error occured : {0}", ex.ToString()), "Sample error");
            }
        }
예제 #4
0
        public bool clearSelection()
        {
            var layers          = MapView.Active.Map.Layers;
            var parcelLayerName = config.getConfig("Działki", "parcelsLayer");

            if (parcelLayerName == null)
            {
                MessageBox.Show("Brak wybranej konfiguracji");
                return(false);
            }
            FeatureLayer layer = (FeatureLayer)layers.Where((currentLayer) =>
            {
                return(currentLayer.Name.Equals(parcelLayerName));
            }).First();

            if (layer == null)
            {
                MessageBox.Show("Brak podanej warstwy");
                return(false);
            }
            Task t = QueuedTask.Run(() =>
            {
                layer.ClearSelection();
            });

            return(true);
        }
예제 #5
0
        // Update the UI grid with bird data queried from local gdb
        private async Task RefreshDataView()
        {
            LocalBirdFeatures = await _localBirdsLayer.FeatureTable.QueryAsync(new QueryFilter()
            {
                WhereClause = "1=1"
            });

            QueryTask queryTask = new QueryTask(new Uri(_onlineBirdsLayer.ServiceUri + "/1"));
            Query     query     = new Query("1=1")
            {
                Geometry = MyMapView.Extent, OutFields = new OutFields(new string[] { "globalid" })
            };
            var queryResult = await queryTask.ExecuteAsync(query);

            var onlineBirdIds = queryResult.FeatureSet.Features.Select(f => f.Attributes["globalid"]);
            var localBirdIds  = LocalBirdFeatures.Select(b => b.Attributes["globalid"]);
            var newBirdsIds   = localBirdIds.Except(onlineBirdIds);

            var newBirdOIDs = from newBird in LocalBirdFeatures
                              join newBirdId in newBirdsIds on newBird.Attributes["globalid"] equals newBirdId
                              select(long) newBird.Attributes["objectid"];

            _localBirdsLayer.ClearSelection();
            _localBirdsLayer.SelectFeatures(newBirdOIDs.ToArray());
        }
예제 #6
0
        private void moveLandmarkMouseUp(object sender, MouseEventArgs e)
        {
            Panel_Other otherControls = getOtherControls();

            if (e.Button == MouseButtons.Right && otherControls.toolStripMoveLandmark.BackColor == Color.LightSkyBlue)
            {
                otherControls.toolStripMoveLandmark.BackColor = originalColor;
                moveLandmark(sender, e);
                return;
            }
            if (!movingLandmark)
            {
                return;
            }
            FeatureLayer selectionLayer = (FeatureLayer)Layer;

            Properties.Settings.Default.Save();
            selectionLayer.ClearSelection();
            selectionLayer.DataSet.Save();
            setSymbolizer();
            Project.map.Invalidate();
            Project.map.Refresh();
            Project.map.ResetBuffer();
            Project.map.Update();
            if (otherControls.toolStripMoveLandmark.BackColor != originalColor)
            {
                return;
            }
            movingLandmark           = false;
            Project.map.FunctionMode = FunctionMode.Select;
            otherControls.toolStripMoveLandmark.BackColor = originalColor;
        }
예제 #7
0
        public async void UpdateExtents(object sender, RoutedEventArgs e)
        {
            statusTextBlock.Text = "Updating Extents";

            QueryParameters queryParams = new QueryParameters();

            queryParams.WhereClause = "TaxID LIKE '" + _currTaxID + "'";

            FeatureQueryResult queryResult = await sfFeatTable.QueryFeaturesAsync(queryParams);

            List <Feature> features = queryResult.ToList();

            if (features.Any())
            {
                EnvelopeBuilder envBuilder = new EnvelopeBuilder(SpatialReference.Create(102715));

                foreach (Feature feature in features)
                {
                    envBuilder.UnionOf(feature.Geometry.Extent);
                    newFeatureLayer.ClearSelection();
                    newFeatureLayer.SelectFeature(feature);
                }

                await MyMapView.SetViewpointGeometryAsync(envBuilder.ToGeometry(), 20);

                statusTextBlock.Text = "";
            }

            else
            {
                statusTextBlock.Text = "No parcel found for current query";
            }
        }
        private async void MapView_Tapped(object sender, GeoViewInputEventArgs e)
        {
            // Clear any existing selection.
            _damageLayer.ClearSelection();
            _addButton.Enabled           = false;
            _attachmentsListView.Enabled = false;

            try
            {
                // Perform an identify to determine if a user tapped on a feature.
                IdentifyLayerResult identifyResult = await _myMapView.IdentifyLayerAsync(_damageLayer, e.Position, 2, false);

                // Do nothing if there are no results.
                if (!identifyResult.GeoElements.Any())
                {
                    return;
                }

                // Get the selected feature as an ArcGISFeature. It is assumed that all GeoElements in the result are of type ArcGISFeature.
                GeoElement tappedElement = identifyResult.GeoElements.First();
                _selectedFeature = (ArcGISFeature)tappedElement;

                // Update the UI.
                UpdateUIForFeature();
                _addButton.Enabled           = true;
                _attachmentsListView.Enabled = true;
            }
            catch (Exception ex)
            {
                ShowMessage(ex.ToString(), "Error selecting feature");
            }
        }
예제 #9
0
        private void updateChanges(object sender, EventArgs e)
        {
            FeatureLayer selectionLayer = (FeatureLayer)moduleRoads.Layer;
            string       tamsidcolumn   = Project.settings.GetValue(ModuleName + "_f_TAMSID");
            string       tamsidsCSV     = string.Join(",", moduleRoads.tamsids.ToArray());

            foreach (DataRow row in selectionLayer.DataSet.DataTable.Select(tamsidcolumn + " IN (" + tamsidsCSV + ")"))
            {
                foreach (DataRow r in reportTable.Rows)
                {
                    int x, y;
                    Int32.TryParse(r["ID"].ToString(), out x);
                    Int32.TryParse(row["TAMS_ID"].ToString(), out y);
                    if (x == y)
                    {
                        row["TAMSROADRSL"]   = r["RSL"];
                        row["TAMSTREATMENT"] = r["Treatment"];
                    }
                }
            }

            selectionLayer.ClearSelection();
            moduleRoads.symbols.setSymbolizer();
            Project.map.Invalidate();
            Project.map.Refresh();
            Project.map.ResetBuffer();
            Project.map.Update();
        }
예제 #10
0
        /// <summary>
        /// 해당시설물의 지도상위치 찾아가기(업무화면에서 호출됨)
        /// </summary>
        /// <param name="FTR_CDE"></param>
        /// <param name="FTR_IDN"></param>
        /// <returns></returns>
        public async Task findFtrAsync(string FTR_CDE, string FTR_IDN)
        {
            string layerNm = "";

            try
            {
                layerNm = GisCmm.GetLayerNm(FTR_CDE);
                if ("".Equals(layerNm))
                {
                    MessageBox.Show("잘못된 레이어입니다.");
                    return;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("잘못된 레이어입니다.");
                return;
            }


            //0.해당레이어표시 - 내부에서자동으로 로딩여부 체크함
            ///ShowShapeLayer(mapView, GisCmm.GetLayerNm(FTR_CDE), true);

            //1.해당레이어 가져오기
            FeatureLayer layer = CmmRun.layers[GisCmm.GetLayerNm(FTR_CDE)];



            // Remove any previous feature selections that may have been made.
            layer.ClearSelection();

            // Begin query process.
            await QueryStateFeature(FTR_CDE, FTR_IDN, layer);
        }
예제 #11
0
        private void clearAll(object sender, RoutedEventArgs e)
        {
            parcels = new List <ParcelModel>();
            primaryNavigator.Items.Clear();
            string layerName = config.getConfig("Działki", "parcelsLayer");

            if (layerName == null)
            {
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Brak konfiguracji dla warstw. Stwórz nową");
                return;
            }
            var          layers       = MapView.Active.Map.Layers;
            FeatureLayer parcelsLayer = (FeatureLayer)layers.Where((layer) =>
            {
                return(layerName.Equals(layer.Name));
            }).First();

            if (parcelsLayer == null)
            {
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Brak konfiguracji dla warstw. Stwórz nową");
                return;
            }
            Task t = QueuedTask.Run(() =>
            {
                parcelsLayer.ClearSelection();
            });
        }
예제 #12
0
        /// <summary>
        /// Action effectuée au clic sur la carte
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void MyView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            // au clic, on va aller faire un identify sur la couche.
            IdentifyLayerResult identifyResult = await myView.IdentifyLayerAsync(stationnements, e.Position, 5);

            // on clear la sélection existante
            stationnements.ClearSelection();
            // on cache le formulaire attributaire
            AttributesForm.IsVisible = false;

            // Si on récupère un objet (ou plusieurs)
            if (identifyResult.GeoElements.Count > 0)
            {
                // on affiche le formulaire
                AttributesForm.IsVisible = true;

                // on récupère le premier résultat
                Feature feature = identifyResult.GeoElements[0] as Feature;
                // on sélectionne l'objet sur la carte
                stationnements.SelectFeature(feature);

                // Mise à jour de l'IHM
                // implémentation simple
                attributeTitle.Title = "Stationnement : " + feature.Attributes["LibVoie"].ToString();
                LibVoie.Detail       = feature.Attributes["LibVoie"].ToString();
                Abonnement.Detail    = feature.Attributes["Abonnement"].ToString();
                QUARTIER.Detail      = feature.Attributes["QUARTIER"].ToString();
                SECTEUR.Detail       = feature.Attributes["SECTEUR"].ToString();
                ZONE_.Detail         = feature.Attributes["ZONE_"].ToString();
            }
        }
예제 #13
0
        /// <summary>
        /// this method display the value of country name region name and its population when a location is tapped on the map.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void MyMap_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            try
            {
                //identify all layers in the MapView, passing the tap point, tolerance,
                //types to return, and max results
                IReadOnlyList <IdentifyLayerResult> idlayerResults =
                    await MyMapView.IdentifyLayersAsync(e.Position, 10, false, 5);

                if (idlayerResults.Count > 0)
                {
                    IdentifyLayerResult idResults = idlayerResults.FirstOrDefault();
                    FeatureLayer        idLayer   = idResults.LayerContent as FeatureLayer;
                    idLayer.ClearSelection();

                    CountryTitleLabel.Content    = "Country";
                    RegionTitleLabel.Content     = "Region";
                    PopulationTitleLabel.Content = "2015 Population";

                    foreach (GeoElement idElement in idResults.GeoElements)
                    {
                        Feature idFeature = idElement as Feature;
                        idLayer.SelectFeature(idFeature);

                        IDictionary <string, object> attributes = idFeature.Attributes;
                        string attKey  = string.Empty;
                        object attVal1 = new object();

                        foreach (var attribute in attributes)
                        {
                            attKey  = attribute.Key;
                            attVal1 = attribute.Value;

                            if (string.Compare(attKey, "Country") == 0)
                            {
                                CountryValueLabel.Content = attVal1;
                            }

                            if (string.Compare(attKey, "Major_Region") == 0)
                            {
                                RegionValueLabel.Content = attVal1;
                            }

                            if (string.Compare(attKey, "pop2015") == 0)
                            {
                                string pop = attVal1 + "000";
                                int.TryParse(pop, out int result);
                                string formatString = String.Format("{0:n0}", result);
                                PopulationValueLabel.Content = formatString;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private async void MyMapViewOnGeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Clear any existing feature selection and results list
            _myFeatureLayer.ClearSelection();
            MyResultsView.ItemsSource = null;

            // Identify the tapped feature
            IdentifyLayerResult results = await MyMapView.IdentifyLayerAsync(_myFeatureLayer, e.Position, 10, false);

            // Return if there are no results
            if (results.GeoElements.Count < 1)
            {
                return;
            }

            // Get the first result
            ArcGISFeature myFeature = (ArcGISFeature)results.GeoElements.First();

            // Select the feature
            _myFeatureLayer.SelectFeature(myFeature);

            // Get the feature table for the feature
            ArcGISFeatureTable myFeatureTable = (ArcGISFeatureTable)myFeature.FeatureTable;

            // Query related features
            IReadOnlyList <RelatedFeatureQueryResult> relatedFeaturesResult = await myFeatureTable.QueryRelatedFeaturesAsync(myFeature);

            // Create a list to hold the formatted results of the query
            List <String> queryResultsForUi = new List <string>();

            // For each query result
            foreach (RelatedFeatureQueryResult result in relatedFeaturesResult)
            {
                // And then for each feature in the result
                foreach (Feature resultFeature in result)
                {
                    // Get a reference to the feature's table
                    ArcGISFeatureTable relatedTable = (ArcGISFeatureTable)resultFeature.FeatureTable;

                    // Get the display field name - this is the name of the field that is intended for display
                    string displayFieldName = relatedTable.LayerInfo.DisplayFieldName;

                    // Get the name of the feature's table
                    string tableName = relatedTable.TableName;

                    // Get the display name for the feature
                    string featureDisplayname = resultFeature.Attributes[displayFieldName].ToString();

                    // Create a formatted result string
                    string formattedResult = $"{tableName} - {featureDisplayname}";

                    // Add the result to the list
                    queryResultsForUi.Add(formattedResult);
                }
            }

            // Update the UI with the result list
            MyResultsView.ItemsSource = queryResultsForUi;
        }
예제 #15
0
        private void VersionButtonClicked(object sender, EventArgs e)
        {
            // Check if user version has been created.
            if (_userCreatedVersionName != null)
            {
                _ = SwitchVersion();
            }
            else
            {
                // Display UI for creating a new version.
                SwitchView(VersionView);
            }

            // Clear the selection.
            _featureLayer.ClearSelection();
            _selectedFeature = null;
        }
        private async void OnQueryClicked(object sender, EventArgs e)
        {
            // Remove any previous feature selections that may have been made
            _featureLayer.ClearSelection();

            // Begin query process
            await QueryStateFeature(queryEntry.Text);
        }
예제 #17
0
        private void ClearExpression(object sender, EventArgs e)
        {
            select_expression.Clear();

            uniqueList.Items.Clear();

            _attiveLayer.ClearSelection();
        }
예제 #18
0
 private void DoSelectFeature(Feature feature)
 {
     featureLayer.ClearSelection();
     if (feature != null)
     {
         featureLayer.SelectFeature(feature);
         MessageBox.Show("Address of the parcel: " + _feature.Attributes["Address"].ToString());
     }
 }
예제 #19
0
        private void customRoadReport(FormQueryBuilder tableFilters)
        {
            bool   selectResults = false;
            string surfaceType   = tableFilters.getSurface();
            string query         = tableFilters.getQuery();

            if (tableFilters.checkBoxSelectResults.Checked && query != "SELECT * FROM road")
            {
                selectResults = true;
            }
            query += " GROUP BY TAMSID ORDER BY TAMSID ASC, survey_date DESC;";
            DataTable results = Database.GetDataByQuery(Project.conn, query);

            if (results.Rows.Count == 0)
            {
                MessageBox.Show("No roads matching the given description were found.");
                return;
            }
            DataTable    outputTable    = roadReports.addColumns(surfaceType);
            FormOutput   report         = new FormOutput(Project, moduleRoads);
            FeatureLayer selectionLayer = (FeatureLayer)moduleRoads.Layer;

            selectionLayer.ClearSelection();
            foreach (DataRow row in results.Rows)
            {
                if (selectResults)
                {
                    String tamsidcolumn = Project.settings.GetValue("road_f_TAMSID");
                    selectionLayer.SelectByAttribute(tamsidcolumn + " = " + row["TAMSID"], ModifySelectionMode.Append);
                }

                DataRow nr   = outputTable.NewRow();
                string  note = row["notes"].ToString().Split(new[] { '\r', '\n' }).FirstOrDefault(); //retrive most recent note

                int oldNoteLength = note.Length;
                int maxLength     = 17;
                if (!string.IsNullOrEmpty(note))
                {
                    note = note.Substring(0, Math.Min(oldNoteLength, maxLength));
                    if (note.Length == maxLength)
                    {
                        note += "...";
                    }
                }
                roadReports.addRows(nr, row, surfaceType);
                outputTable.Rows.Add(nr);
            }
            report.dataGridViewReport.DataSource = outputTable;
            report.Text = "Treatment Report";
            report.Show();
            if (selectResults)
            {
                moduleRoads.selectionChanged();
            }
        }
예제 #20
0
파일: Main.cs 프로젝트: agrc/TrailsAddin
        private async void AddSelectedToTemp()
        {
            await QueuedTask.Run(() =>
            {
                using (RowCursor segmentsCursor = SegmentsLayer.GetSelection().Search(null))
                {
                    EditOperation operation = new EditOperation();
                    operation.Name          = "add selected to temp segments";
                    List <string> newIDs    = new List <string>();
                    while (segmentsCursor.MoveNext())
                    {
                        var id = EnsureIDForSegment(segmentsCursor.Current, operation);

                        if (tempSegmentIDs.Contains(id))
                        {
                            MessageBox.Show($"This segment ({id}) has already been selected for the current part. Try creating a new part.");
                            continue;
                        }

                        CopyRowValues(segmentsCursor.Current, currentPart, operation);

                        newIDs.Add(id);
                    }

                    tempSegmentIDs.AddRange(newIDs);

                    operation.SetOnUndone(() =>
                    {
                        tempSegmentIDs.RemoveRange(tempSegmentIDs.Count - newIDs.Count, newIDs.Count);
                    });

                    bool success = operation.Execute();
                    if (!success)
                    {
                        MessageBox.Show(operation.ErrorMessage);
                    }

                    SegmentsLayer.ClearSelection();
                    TempSegmentsLayer.ClearSelection();
                }
            });
        }
예제 #21
0
        /// <summary>
        /// 到達圏解析結果のクリア
        /// </summary>
        private void ClearAnalysisResult()
        {
            //到達圏グラフィックをクリア
            serviceAreaGraphic = null;

            //到達圏解析結果表示用グラフィックスレイヤのグラフィックをクリア
            serviceAreaResultLayer.Graphics.Clear();

            //物件レイヤのフィーチャの選択をすべてクリア
            buildingLayer.ClearSelection();
        }
예제 #22
0
        private void VersionButtonPressed(object sender, RoutedEventArgs e)
        {
            // Check if user version has been created.
            if (_userCreatedVersionName != null)
            {
                _ = SwitchVersion();
            }
            else
            {
                // Display UI for creating a new version.
                VersionCreator.Visibility = Visibility.Visible;
            }

            // Ensure the attribute picker is closed.
            AttributePicker.Visibility = Visibility.Collapsed;

            // Clear the selection.
            _featureLayer.ClearSelection();
            _selectedFeature = null;
        }
 private void ClearSelectButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         _featureLayer.ClearSelection();
         SetSelectionCountUI();
     }
     catch (Exception ex)
     {
         var _x = new MessageDialog("Selection Error: " + ex.Message, "Feature Layer Selection Sample").ShowAsync();
     }
 }
        private async Task QueryStateFeature(string stateName)
        {
            try
            {
                // Clear the existing selection.
                _featureLayer.ClearSelection();

                // Create a query parameters that will be used to Query the feature table.
                QueryParameters queryParams = new QueryParameters();

                // Trim whitespace on the state name to prevent broken queries.
                string formattedStateName = stateName.Trim().ToUpper();

                // Construct and assign the where clause that will be used to query the feature table.
                queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + formattedStateName + "%'";

                // Query the feature table.
                FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams);

                // Cast the QueryResult to a List so the results can be interrogated.
                List <Feature> features = queryResult.ToList();

                if (features.Any())
                {
                    // Create an envelope.
                    EnvelopeBuilder envBuilder = new EnvelopeBuilder(SpatialReferences.WebMercator);

                    // Loop over each feature from the query result.
                    foreach (Feature feature in features)
                    {
                        // Add the extent of each matching feature to the envelope.
                        envBuilder.UnionOf(feature.Geometry.Extent);

                        // Select each feature.
                        _featureLayer.SelectFeature(feature);
                    }

                    // Zoom to the extent of the selected feature(s).
                    await _myMapView.SetViewpointGeometryAsync(envBuilder.ToGeometry(), 50);
                }
                else
                {
                    UIAlertView alert = new UIAlertView("State Not Found!", "Add a valid state name.", (IUIAlertViewDelegate)null, "OK", null);
                    alert.Show();
                }
            }
            catch (Exception ex)
            {
                UIAlertView alert = new UIAlertView("Sample error", ex.ToString(), (IUIAlertViewDelegate)null, "OK", null);
                alert.Show();
            }
        }
예제 #25
0
        // 清楚选择要素
        private void cleanSelectCsy_Click(object sender, RoutedEventArgs e)
        {
            int len = myMapView.Map.OperationalLayers.Count;

            for (int i = 0; i < len; i++)
            {
                FeatureLayer featureLayer = (FeatureLayer)myMapView.Map.OperationalLayers[i];
                featureLayer.ClearSelection();

                //GraphicsOverlay g = (GraphicsOverlay)myMapView.GraphicsOverlays[i];
                //myMapView.GraphicsOverlays.
            }
        }
예제 #26
0
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            this.MyMapView.GraphicsOverlays[0].Graphics.Clear();

            QueryParameters queryParameters = new QueryParameters();

            queryParameters.Geometry = e.Location;
            string sum = string.Empty;
            List <CalloutDefinition> calloutDefinitions = new List <CalloutDefinition>();
            //List<Feature> features = new List<Feature>();
            StringBuilder stringBuilder = new StringBuilder();

            this.ViewModel.Fields.Clear();
            foreach (var table in this.ViewModel.ServiceFeatureTables)
            {
                FeatureTable arcGISFeatureTable = table as FeatureTable;
                FeatureLayer layer = table.Layer as FeatureLayer;
                layer.ClearSelection();
                if (this.ViewModel.EsriMap.OperationalLayers.Contains(layer))
                {
                    string[]           outputFields = { "*" };
                    FeatureQueryResult fqr          = await table.QueryFeaturesAsync(queryParameters, QueryFeatureFields.LoadAll);

                    Feature feature = fqr.FirstOrDefault();
                    if (feature != null)
                    {
                        stringBuilder.Append(feature.Attributes.First().Value + Environment.NewLine);
                        //features.Add(feature);
                        layer.SelectFeature(feature);
                        StringBuilder       sb      = new StringBuilder();
                        FeatureTableWrapper wrapper = new FeatureTableWrapper();
                        wrapper.TableName = layer.FeatureTable.TableName;
                        wrapper.KeyValues = new Dictionary <string, string>();
                        foreach (var att in feature.Attributes)
                        {
                            if (!wrapper.KeyValues.ContainsKey(att.Key))
                            {
                                wrapper.KeyValues.Add(att.Key, att.Value.ToString());
                            }
                        }
                        this.ViewModel.Fields.Add(wrapper);
                    }
                }
            }
            this.MyMapView.GraphicsOverlays[0].Graphics.Add(new Esri.ArcGISRuntime.UI.Graphic(e.Location));
            CalloutDefinition callout = new CalloutDefinition(this.ViewModel.GeoviProject.Name, stringBuilder.ToString());
            Point             point   = new Point(e.Location.X, e.Location.Y);

            this.MyMapView.ShowCalloutAt(e.Location, callout);
        }
        private async void MapView_Tapped(object sender, GeoViewInputEventArgs e)
        {
            // Clear any existing selection.
            _damageLayer.ClearSelection();

            // Dismiss any existing callouts.
            MyMapView.DismissCallout();

            // Reset the dropdown.
            DamageTypeDropDown.IsEnabled     = false;
            DamageTypeDropDown.SelectedIndex = -1;

            try
            {
                // Perform an identify to determine if a user tapped on a feature.
                IdentifyLayerResult identifyResult = await MyMapView.IdentifyLayerAsync(_damageLayer, e.Position, 2, false);

                // Do nothing if there are no results.
                if (!identifyResult.GeoElements.Any())
                {
                    return;
                }

                // Get the tapped feature.
                _selectedFeature = (ArcGISFeature)identifyResult.GeoElements.First();

                // Select the feature.
                _damageLayer.SelectFeature(_selectedFeature);

                // Update the UI for the selection.
                UpdateUiForSelectedFeature();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "There was a problem.");
            }
        }
        private async void MapView_Tapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            // Clear any existing selection.
            _damageLayer.ClearSelection();

            // Dismiss any existing callouts.
            MyMapView.DismissCallout();

            // Reset the picker.
            DamageTypePicker.IsEnabled     = false;
            DamageTypePicker.SelectedIndex = -1;

            try
            {
                // Perform an identify to determine if a user tapped on a feature.
                IdentifyLayerResult identifyResult = await MyMapView.IdentifyLayerAsync(_damageLayer, e.Position, 8, false);

                // Do nothing if there are no results.
                if (!identifyResult.GeoElements.Any())
                {
                    return;
                }

                // Get the tapped feature.
                _selectedFeature = (ArcGISFeature)identifyResult.GeoElements.First();

                // Select the feature.
                _damageLayer.SelectFeature(_selectedFeature);

                // Update the UI for the selection.
                UpdateUiForSelectedFeature();
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error selecting feature.", ex.ToString(), "OK");
            }
        }
예제 #29
0
        private async void MapView_Tapped(object sender, GeoViewInputEventArgs e)
        {
            // Clear any existing selection.
            _damageLayer.ClearSelection();

            try
            {
                // Perform an identify to determine if a user tapped on a feature.
                IdentifyLayerResult identifyResult = await _myMapView.IdentifyLayerAsync(_damageLayer, e.Position, 2, false);

                // Do nothing if there are no results.
                if (!identifyResult.GeoElements.Any())
                {
                    return;
                }

                // Get the selected feature as an ArcGISFeature. It is assumed that all GeoElements in the result are of type ArcGISFeature.
                GeoElement    tappedElement = identifyResult.GeoElements.First();
                ArcGISFeature tappedFeature = (ArcGISFeature)tappedElement;

                // Select the feature.
                _damageLayer.SelectFeature(tappedFeature);

                // Create the view controller.
                AttachmentsTableView attachmentsTableViewController = new AttachmentsTableView(tappedFeature);

                // Present the view controller.
                NavigationController.PushViewController(attachmentsTableViewController, true);

                // Deselect the feature.
                _damageLayer.ClearSelection();
            }
            catch (Exception ex)
            {
                ShowMessage(ex.ToString(), "Error selecting feature");
            }
        }
예제 #30
0
        private async void QueryEntry_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            try
            {
                // Remove any previous feature selections that may have been made
                _featureLayer.ClearSelection();

                // Begin query process
                await QueryStateFeature(args.QueryText);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }