コード例 #1
0
        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;
        }
        private async void OnMapViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            try
            {
                IdentifyLayerResult idResult = await MyMapView.IdentifyLayerAsync(relauteFeatureLayer, e.Position, 5, false);

                ArcGISFeature serviceRequestFeature = idResult.GeoElements.FirstOrDefault() as ArcGISFeature;

                if (serviceRequestFeature == null)
                {
                    return;
                }

                ArcGISFeatureTable serviceRequestTable = serviceRequestFeature.FeatureTable as ArcGISFeatureTable;

                IReadOnlyList <ArcGISFeatureTable> relatedTables = serviceRequestTable.GetRelatedTables();

                if (relatedTables.Count > 0)
                {
                    // Get the comments from the relationship results
                    ArcGISFeatureTable relatedComments = relatedTables.FirstOrDefault();

                    await relatedComments.LoadAsync();

                    if (relatedComments.LoadStatus == LoadStatus.Loaded)
                    {
                        ArcGISFeature newComment = relatedComments.CreateFeature() as ArcGISFeature;

                        newComment.Attributes["鷗_FLN_TEXT_須"] = "Please show up on time!";

                        // Relate the selected service request to the new comment
                        serviceRequestFeature.RelateFeature(newComment);


                        /*
                         * var getUpdatedFeature = await relatedComments.GetUpdatedFeaturesAsync();
                         * ArcGISFeature test = (ArcGISFeature)getUpdatedFeature.FirstOrDefault();
                         *
                         * await test.LoadAsync();
                         * test.Attributes["鷗_FLN_TEXT_須"] = "鷗_JPSTRING_須 | 神谷";
                         *
                         * await relatedComments.UpdateFeatureAsync(test);
                         * serviceRequestFeature.RelateFeature(test);
                         *
                         * ArcGISFeature newComment = relatedComments.CreateFeature() as ArcGISFeature;
                         */
                        //serviceRequestFeature.RelateFeature(f);
                    }
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("検索のエラー", ex.ToString(), "OK");
            }
        }
コード例 #3
0
ファイル: MapPage.xaml.cs プロジェクト: GeoGeeks/OnMap
        public MapPage()
        {
            this.InitializeComponent();

            MyMapView.LocationDisplay.LocationProvider = new SystemLocationProvider();
            MyMapView.LocationDisplay.LocationProvider.StartAsync();

            HardwareButtons.BackPressed += HardwareButtons_BackPressed;

            MyMapView.Loaded          += MyMapView_Loaded;
            _locatorTask               = new OnlineLocatorTask(new Uri(OnlineLocatorUrl));
            _locatorTask.AutoNormalize = true;

            _directionPointSymbol = LayoutRoot.Resources["directionPointSymbol"] as Esri.ArcGISRuntime.Symbology.Symbol;
            _stopsOverlay         = MyMapView.GraphicsOverlays["StopsOverlay"];
            _routesOverlay        = MyMapView.GraphicsOverlays["RoutesOverlay"];
            _directionsOverlay    = MyMapView.GraphicsOverlays["DirectionsOverlay"];
            _myLocationOverlay    = MyMapView.GraphicsOverlays["LocationOverlay"];
            _routeTask            = new OnlineRouteTask(new Uri(OnlineRoutingService));

            _campos = new Dictionary <String, String>();
            if (PortalSearch.GetSelectedItem().Map.Layers.Count() > 0)
            {
                foreach (Layer i in PortalSearch.GetSelectedItem().Map.Layers)
                {
                    try
                    {
                        if (!((FeatureLayer)i).FeatureTable.IsReadOnly && ((FeatureLayer)i).FeatureTable.GeometryType == GeometryType.Point)
                        {
                            _layer = i as FeatureLayer;
                            _table = (ArcGISFeatureTable)_layer.FeatureTable;
                            MenuFlyoutAddButton.IsEnabled = true;
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DestinationRelationshipViewModel"/> class.
 /// </summary>
 public DestinationRelationshipViewModel(RelationshipInfo relationshipInfo, ArcGISFeatureTable relatedTable, ConnectivityMode connectivityMode)
 {
     RelationshipInfo = relationshipInfo;
     FeatureTable     = relatedTable;
     ConnectivityMode = connectivityMode;
 }
コード例 #5
0
 public OriginRelationship(ArcGISFeatureTable relatedTable, RelationshipInfo relationshipInfo, ObservableCollection <OriginRelationshipViewModel> originRelationshipViewModelCollection)
 {
     RelatedTable     = relatedTable;
     RelationshipInfo = relationshipInfo;
     OriginRelationshipViewModelCollection = originRelationshipViewModelCollection;
 }
        private async void MyMapViewOnGeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            try
            {
                // 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;
                }

                // Show the loading indicator (this can take a while).
                LoadingProgress.Visibility = Visibility.Visible;

                // 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;

                // Hide the loading indicator.
                LoadingProgress.Visibility = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                await new MessageDialog2(ex.ToString(), "Error").ShowAsync();
            }
        }
コード例 #7
0
        private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Clear any existing feature selection and results list.
            _myFeatureLayer.ClearSelection();
            _tableView.Source = null;
            _tableView.ReloadData();

            try
            {
                // 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);
                    }
                }

                // Create the source for the display list.
                _layerListSource = new LayerListSource(queryResultsForUi);

                // Assign the source to the display view.
                _tableView.Source = _layerListSource;

                // Force the table view to refresh its data.
                _tableView.ReloadData();
            }
            catch (Exception ex)
            {
                new UIAlertView("Error", ex.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
コード例 #8
0
        private async void MyMapViewOnGeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Clear any existing feature selection and results list
            _myFeatureLayer.ClearSelection();
            _myDisplayList.Adapter = null;

            try
            {
                // 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);
                    }
                }

                // Create an array adapter for the layer display
                ArrayAdapter adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, queryResultsForUi);

                // Apply the adapter to show the results in the UI
                _myDisplayList.Adapter = adapter;
            }
            catch (Exception ex)
            {
                new AlertDialog.Builder(this).SetMessage(ex.ToString()).SetTitle("Error").Show();
            }
        }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DestinationRelationshipViewModel"/> class.
 /// </summary>
 public OriginRelationshipViewModel(ArcGISFeatureTable relatedTable, ConnectivityMode connectivityMode)
 {
     RelatedTable     = relatedTable;
     ConnectivityMode = connectivityMode;
 }