Exemple #1
0
        /**
         * ローカルgeodatabaseにポイントを追加する
         **/
        private async void addFeature(MapPoint pPoint)
        {
            if (mGdbFeatureTable == null)
            {
                return;
            }

            if (!mGdbFeatureTable.CanAdd())
            {
                // Deal with indicated error
                return;
            }

            // 項目にデータを入れる
            var attributes = new Dictionary <string, object>();

            attributes.Add("name", "ESRIジャパンnow!");

            Feature addedFeature = mGdbFeatureTable.CreateFeature(attributes, pPoint);

            await mGdbFeatureTable.AddFeatureAsync(addedFeature);

            FeatureQueryResult results = await mGdbFeatureTable.GetAddedFeaturesAsync();

            foreach (var r in results)
            {
                Console.WriteLine("add point geodatabase : '" + r.Attributes["name"]);
            }
        }
Exemple #2
0
        private async void AddNewFeature(object sender, EventArgs args)
        {
            // See if it was the "Birds" or "Marine" button that was clicked
            Button addFeatureButton = (Button)sender;

            try
            {
                // Cancel execution of the sketch task if it is already active
                if (_mapView.SketchEditor.CancelCommand.CanExecute(null))
                {
                    _mapView.SketchEditor.CancelCommand.Execute(null);
                }

                // Store the correct table to edit (for the button clicked)
                GeodatabaseFeatureTable editTable = null;
                if (addFeatureButton == _addBirdButton)
                {
                    editTable = _birdTable;
                }
                else
                {
                    editTable = _marineTable;
                }

                // Inform the user which table is being edited
                _messageTextBlock.Text = "Click the map to add a new feature to the geodatabase table '" + editTable.TableName + "'";

                // Create a random value for the 'type' attribute (integer between 1 and 7)
                Random random      = new Random(DateTime.Now.Millisecond);
                int    featureType = random.Next(1, 7);

                // Use the sketch editor to allow the user to draw a point on the map
                MapPoint clickPoint = await _mapView.SketchEditor.StartAsync(SketchCreationMode.Point, false) as MapPoint;

                // Create a new feature (row) in the selected table
                Feature newFeature = editTable.CreateFeature();

                // Set the geometry with the point the user clicked and the 'type' with the random integer
                newFeature.Geometry = clickPoint;
                newFeature.SetAttributeValue("type", featureType);

                // Add the new feature to the table
                await editTable.AddFeatureAsync(newFeature);

                // Clear the message
                _messageTextBlock.Text = "New feature added to the '" + editTable.TableName + "' table";
            }
            catch (TaskCanceledException)
            {
                // Ignore if the edit was canceled
            }
            catch (Exception ex)
            {
                // Report other exception messages
                _messageTextBlock.Text = ex.Message;
            }
        }
Exemple #3
0
        private async void AddNewFeature(bool isMarine)
        {
            try
            {
                // Cancel execution of the sketch task if it is already active.
                if (_mapView.SketchEditor.CancelCommand.CanExecute(null))
                {
                    _mapView.SketchEditor.CancelCommand.Execute(null);
                }

                // Store the correct table to edit (for the button clicked).
                GeodatabaseFeatureTable editTable = isMarine ? _marineTable : _birdTable;

                // Inform the user which table is being edited.
                _statusLabel.Text = "Click the map to add a new feature to the geodatabase table '" + editTable.TableName + "'";

                // Create a random value for the 'type' attribute (integer between 1 and 7).
                Random random      = new Random(DateTime.Now.Millisecond);
                int    featureType = random.Next(1, 7);

                // Use the sketch editor to allow the user to draw a point on the map.
                MapPoint clickPoint = await _mapView.SketchEditor.StartAsync(SketchCreationMode.Point, false) as MapPoint;

                // Create a new feature (row) in the selected table.
                Feature newFeature = editTable.CreateFeature();

                // Set the geometry with the point the user clicked and the 'type' with the random integer.
                newFeature.Geometry = clickPoint;
                newFeature.SetAttributeValue("type", featureType);

                // Add the new feature to the table.
                await editTable.AddFeatureAsync(newFeature);

                // Clear the message.
                _statusLabel.Text = "New feature added to the '" + editTable.TableName + "' table";
            }
            catch (TaskCanceledException)
            {
                // Ignore if the edit was canceled.
            }
            catch (Exception ex)
            {
                // Report other exception messages.
                _statusLabel.Text = ex.Message;
            }
        }
Exemple #4
0
        private async void addFeature(MapPoint pPoint)
        {
            // 新しいポイントデータを作成して mGdbFeatureTable に反映する
            var attributes = new Dictionary <string, object>();

            attributes.Add("BuildingName", "Xamarin はいいぞ!");
            attributes.Add("Age", 10);

            Feature addedFeature = mGdbFeatureTable.CreateFeature(attributes, pPoint);

            try {
                await mGdbFeatureTable.AddFeatureAsync(addedFeature);
            }
            catch (Exception ex)
            {
                DisplayAlert("ポイント追加", ex.Message, "OK");
            }
        }