コード例 #1
0
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs mapClickPoint)
        {
            IdentifyLayerResult idResult = await MyMapView.IdentifyLayerAsync(serviceRequestLayer, mapClickPoint.Position, 5, false);

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

            if (serviceRequestFeature == null)
            {
                return;
            }

            // Create a new feature in the comments table
            ArcGISFeature newComment = relatedTable.CreateFeature() as ArcGISFeature;


            // Add comment text to the 'comments' attribute
            newComment.Attributes["comments"] = "Please show up on time!";


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

            var results = await relatedTable.ApplyEditsAsync();
        }
        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");
            }
        }