Exemplo n.º 1
0
        private async void Initialize()
        {
            // Create a new map to display in the map view with a streets basemap.
            MyMapView.Map = new Map(BasemapStyle.ArcGISStreets);

            // Get the path to the downloaded mobile geodatabase (.geodatabase file).
            string mobileGeodatabaseFilePath = GetMobileGeodatabasePath();

            try
            {
                // Open the mobile geodatabase.
                Geodatabase mobileGeodatabase = await Geodatabase.OpenAsync(mobileGeodatabaseFilePath);

                // Get the 'Trailheads' geodatabase feature table from the mobile geodatabase.
                GeodatabaseFeatureTable trailheadsGeodatabaseFeatureTable = mobileGeodatabase.GeodatabaseFeatureTable("Trailheads");

                // Asynchronously load the 'Trailheads' geodatabase feature table.
                await trailheadsGeodatabaseFeatureTable.LoadAsync();

                // Create a feature layer based on the geodatabase feature table.
                FeatureLayer trailheadsFeatureLayer = new FeatureLayer(trailheadsGeodatabaseFeatureTable);

                // Add the feature layer to the operations layers collection of the map.
                MyMapView.Map.OperationalLayers.Add(trailheadsFeatureLayer);

                // Zoom the map to the extent of the feature layer.
                await MyMapView.SetViewpointGeometryAsync(trailheadsFeatureLayer.FullExtent, 50);
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }
Exemplo n.º 2
0
        private async void Initialize()
        {
            // Create a new map to display in the map view with a streets basemap.
            MyMapView.Map = new Map(Basemap.CreateStreets());

            // Get the path to the downloaded mobile geodatabase (.geodatabase file).
            string mobileGeodatabaseFilePath = GetMobileGeodatabasePath();

            // Open the mobile geodatabase.
            Geodatabase mobileGeodatabase = await Geodatabase.OpenAsync(mobileGeodatabaseFilePath);

            // Get the 'Trailheads' geodatabase feature table from the mobile geodatabase.
            GeodatabaseFeatureTable trailheadsGeodatabaseFeatureTable = mobileGeodatabase.GeodatabaseFeatureTable("Trailheads");

            // Asynchronously load the 'Trailheads' geodatabase feature table.
            await trailheadsGeodatabaseFeatureTable.LoadAsync();

            // Create a feature layer based on the geodatabase feature table.
            FeatureLayer trailheadsFeatureLayer = new FeatureLayer(trailheadsGeodatabaseFeatureTable);

            // Add the feature layer to the operations layers collection of the map.
            MyMapView.Map.OperationalLayers.Add(trailheadsFeatureLayer);

            // Zoom the map to the extent of the feature layer.
            await MyMapView.SetViewpointGeometryAsync(trailheadsFeatureLayer.FullExtent);
        }
Exemplo n.º 3
0
        // Function that loads the two point tables from the local geodatabase and displays them as feature layers
        private async void LoadLocalGeodatabaseTables()
        {
            // Read the geodatabase tables and add them as layers
            foreach (GeodatabaseFeatureTable table in _localGeodatabase.GeodatabaseFeatureTables)
            {
                // Load the table so the TableName can be read
                await table.LoadAsync();

                // Store a reference to the Birds table
                if (table.TableName.ToLower().Contains("birds"))
                {
                    _birdTable = table;
                }

                // Store a reference to the Marine table
                if (table.TableName.ToLower().Contains("marine"))
                {
                    _marineTable = table;
                }

                // Create a new feature layer to show the table in the map
                var layer = new FeatureLayer(table);
                Dispatcher.Invoke(() => MyMapView.Map.OperationalLayers.Add(layer));
            }

            // Handle the transaction status changed event
            _localGeodatabase.TransactionStatusChanged += GdbTransactionStatusChanged;

            // Zoom the map view to the extent of the generated local datasets
            Dispatcher.Invoke(() =>
            {
                MyMapView.SetViewpointGeometryAsync(_marineTable.Extent);
                StartEditingButton.IsEnabled = true;
            });
        }
Exemplo n.º 4
0
        private async void Initialize()
        {
            // Create a new map to display in the map view with a streets basemap.
            _myMapView.Map = new Map(Basemap.CreateStreets());

            // Get the path to the downloaded mobile geodatabase (.geodatabase file).
            string mobileGeodatabaseFilePath = DataManager.GetDataFolder("2b0f9e17105847809dfeb04e3cad69e0", "LA_Trails.geodatabase");

            try
            {
                // Open the mobile geodatabase.
                Geodatabase mobileGeodatabase = await Geodatabase.OpenAsync(mobileGeodatabaseFilePath);

                // Get the 'Trailheads' geodatabase feature table from the mobile geodatabase.
                GeodatabaseFeatureTable trailheadsGeodatabaseFeatureTable = mobileGeodatabase.GeodatabaseFeatureTable("Trailheads");

                // Asynchronously load the 'Trailheads' geodatabase feature table.
                await trailheadsGeodatabaseFeatureTable.LoadAsync();

                // Create a feature layer based on the geodatabase feature table.
                FeatureLayer trailheadsFeatureLayer = new FeatureLayer(trailheadsGeodatabaseFeatureTable);

                // Add the feature layer to the operations layers collection of the map.
                _myMapView.Map.OperationalLayers.Add(trailheadsFeatureLayer);

                // Zoom the map to the extent of the feature layer.
                await _myMapView.SetViewpointGeometryAsync(trailheadsFeatureLayer.FullExtent, 50);
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
Exemplo n.º 5
0
        // Summary:
        //     Add a layer in a geodatabase (aka. local layer)
        //     The name of the layer and display options are specified in the LocalELayer
        //
        public static async Task <IGraphicsLayer> addGeodatabaseLayer(
            Map map, LayerDef layerDef, GeodatabaseFeatureTable table,
            int start = 0, int maxFeatures = 0)
        {
            if (layerDef == null || table == null)
            {
                return(null);
            }

            IS3GraphicsLayer gLayer = await featureTable2GraphicsLayer(
                map, table, start, maxFeatures);

            if (gLayer == null)
            {
                return(null);
            }

            gLayer.ID       = table.Name;
            gLayer.MinScale = table.ServiceInfo.MinScale;
            gLayer.MaxScale = table.ServiceInfo.MaxScale;
            setGraphicLayerDisplayOptions(layerDef, gLayer);

            map.Layers.Add(gLayer);
            return(gLayer);
        }
        private async void Initialize()
        {
            // Create a new map to display in the map view with a streets basemap.
            _myMapView.Map = new Map(Basemap.CreateStreets());

            // Get the path to the downloaded mobile geodatabase (.geodatabase file).
            string mobileGeodatabaseFilePath = GetMobileGeodatabasePath();

            try
            {
                // Open the mobile geodatabase.
                Geodatabase mobileGeodatabase = await Geodatabase.OpenAsync(mobileGeodatabaseFilePath);

                // Get the 'Trailheads' geodatabase feature table from the mobile geodatabase.
                GeodatabaseFeatureTable trailheadsGeodatabaseFeatureTable = mobileGeodatabase.GeodatabaseFeatureTable("Trailheads");

                // Asynchronously load the 'Trailheads' geodatabase feature table.
                await trailheadsGeodatabaseFeatureTable.LoadAsync();

                // Create a feature layer based on the geodatabase feature table.
                FeatureLayer trailheadsFeatureLayer = new FeatureLayer(trailheadsGeodatabaseFeatureTable);

                // Add the feature layer to the operations layers collection of the map.
                _myMapView.Map.OperationalLayers.Add(trailheadsFeatureLayer);

                // Zoom the map to the extent of the feature layer.
                await _myMapView.SetViewpointGeometryAsync(trailheadsFeatureLayer.FullExtent, 50);
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }
Exemplo n.º 7
0
        public static LayerDef GenerateDefaultLayerDef(GeodatabaseFeatureTable table)
        {
            LayerDef lyrDef = new LayerDef();

            lyrDef.Name      = table.Name;
            lyrDef.IsVisible = true;
            if (table.GeometryType == GeometryType.Point)
            {
                lyrDef.GeometryType        = IS3.Core.Geometry.GeometryType.Point;
                lyrDef.Color               = Colors.Red;
                lyrDef.FillStyle           = SimpleFillStyle.Solid;
                lyrDef.EnableLabel         = true;
                lyrDef.LabelTextExpression = "[Name]";
            }
            else if (table.GeometryType == GeometryType.Polyline)
            {
                lyrDef.GeometryType = IS3.Core.Geometry.GeometryType.Polyline;
                lyrDef.OutlineColor = Colors.Green;
                lyrDef.Color        = Colors.Green;
                lyrDef.FillStyle    = SimpleFillStyle.Solid;
            }
            else if (table.GeometryType == GeometryType.Polygon)
            {
                lyrDef.GeometryType = IS3.Core.Geometry.GeometryType.Polygon;
                lyrDef.OutlineColor = Colors.Blue;
                lyrDef.Color        = Colors.Blue;
                lyrDef.FillStyle    = SimpleFillStyle.Solid;
            }

            return(lyrDef);
        }
Exemplo n.º 8
0
        // Summary:
        //     Add a layer in a geodatabase (aka. local layer)
        //     The name of the layer and display options are specified in the LocalELayer
        //
        public async Task <IGraphicsLayer> addGeodatabaseLayer(LayerDef layerDef,
                                                               Geodatabase gdb, int start = 0, int maxFeatures = 0)
        {
            if (layerDef == null || gdb == null)
            {
                return(null);
            }

            GeodatabaseFeatureTable table =
                gdb.FeatureTables.FirstOrDefault(t => t.Name == layerDef.Name);

            if (table == null)
            {
                return(null);
            }

            IS3GraphicsLayer gLayer = await featureTable2GraphicsLayer(
                table, start, maxFeatures, false);

            if (gLayer == null)
            {
                return(null);
            }

            gLayer.ID       = layerDef.Name;
            gLayer.MinScale = table.ServiceInfo.MinScale;
            gLayer.MaxScale = table.ServiceInfo.MaxScale;
            setGraphicLayerDisplayOptions(layerDef, gLayer);

            _map.Layers.Add(gLayer);
            return(gLayer);
        }
Exemplo n.º 9
0
        public async void SearchByMeterID(string searchString)
        {
            SimpleLineSymbol sls = new SimpleLineSymbol()
            {
                Color = System.Windows.Media.Colors.Red,
                Style = SimpleLineStyle.Solid,
                Width = 2
            };

            // get the layer and table
            FeatureLayer            featureLayer = this.mapView.Map.Layers[1] as FeatureLayer;
            GeodatabaseFeatureTable table        = featureLayer.FeatureTable as GeodatabaseFeatureTable;

            // Define an attribute query
            var filter = new Esri.ArcGISRuntime.Data.QueryFilter();

            filter.WhereClause = "POST_ID = '" + searchString + "'";     // 666-13080

            // Execute the query and await results
            IEnumerable <Feature> features = await table.QueryAsync(filter);

            // iterate the feature. Should be one in this case.
            foreach (Feature feature in features)
            {
                // Get the MapPoint, Project to Mercator so that we are working in meters
                MapPoint mapPoint      = feature.Geometry as MapPoint;
                MapPoint pointMercator = GeometryEngine.Project(mapPoint, SpatialReferences.WebMercator) as MapPoint;
                Geometry polygon       = GeometryEngine.Buffer(pointMercator, 200);

                // Re-project the polygon to WGS84 so that we can query against the layer which is in WGS84
                Polygon polygonWgs84 = GeometryEngine.Project(polygon, SpatialReferences.Wgs84) as Polygon;

                // add the circle (buffer)
                Graphic graphic = new Graphic();
                graphic.Symbol   = sls;
                graphic.Geometry = polygonWgs84;
                this.graphicsLayer.Graphics.Add(graphic);

                // Make sure the table supports querying
                if (table.SupportsQuery)
                {
                    // setup the query to use the polygon that's in WGS84
                    var query = new Esri.ArcGISRuntime.Data.SpatialQueryFilter();
                    query.Geometry            = polygonWgs84 as Geometry;
                    query.SpatialRelationship = SpatialRelationship.Intersects;

                    var result = await table.QueryAsync(query);

                    int i = 1;
                    // Loop through query results
                    foreach (Esri.ArcGISRuntime.Data.Feature f in result)
                    {
                        // do something with results
                        System.Diagnostics.Debug.WriteLine(i.ToString());
                        i++;
                    }
                }
            }
        }
        private async Task UnregisterAndRemoveMobileMapPackage(MobileMapPackage mobileMapPackage)
        {
            // Unregister all geodatabases from all maps that are part of the mobile map package.
            // Offline areas that are downloaded by using OfflineMapTask will contain a single
            // map in them but it is a good practice to handle the case of multiple maps.
            foreach (Map map in mobileMapPackage.Maps)
            {
                // Find all geodatabases from the used map.
                List <Geodatabase> geodatabasesToUnregister = new List <Geodatabase>();

                // Add all geodatabases used in the feature layers.
                foreach (FeatureLayer featureLayer in map.OperationalLayers.OfType <FeatureLayer>())
                {
                    GeodatabaseFeatureTable geodatabaseFeatureTable = featureLayer.FeatureTable as GeodatabaseFeatureTable;
                    if (geodatabaseFeatureTable == null)
                    {
                        continue;
                    }
                    // Add the geodatabase feature table if it isn't already in the list.
                    if (geodatabasesToUnregister.All(x => x.Path != geodatabaseFeatureTable.Geodatabase.Path))
                    {
                        geodatabasesToUnregister.Add(geodatabaseFeatureTable.Geodatabase);
                    }
                }

                // Add all geodatabases used in a table.
                foreach (FeatureTable featureTable in map.Tables)
                {
                    GeodatabaseFeatureTable geodatabaseFeatureTable = featureTable as GeodatabaseFeatureTable;
                    if (geodatabaseFeatureTable == null)
                    {
                        continue;
                    }
                    // Add the geodatabase feature table if it isn't already in the list.
                    if (geodatabasesToUnregister.All(x => x.Path != geodatabaseFeatureTable.Geodatabase.Path))
                    {
                        geodatabasesToUnregister.Add(geodatabaseFeatureTable.Geodatabase);
                    }
                }

                // Unregister geodatabases that were used.
                foreach (Geodatabase geodatabaseToUnregister in geodatabasesToUnregister)
                {
                    GeodatabaseSyncTask geodatabaSyncTask = await GeodatabaseSyncTask.CreateAsync(geodatabaseToUnregister.Source);

                    await geodatabaSyncTask.UnregisterGeodatabaseAsync(geodatabaseToUnregister);
                }

                // Make sure that all geodatabases are closed and locks released.
                foreach (Geodatabase geodatabase in geodatabasesToUnregister)
                {
                    geodatabase.Close();
                }
            }

            // Remove package.
            Directory.Delete(mobileMapPackage.Path, true);
        }
Exemplo n.º 11
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;
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Adds a MMPK map source.
        /// </summary>
        /// <param name="fileName">the MMPK file</param>
        /// <returns>the opened MMPK</returns>
        public async Task <MobileMapPackage> AddMMPKAsync(string fileName)
        {
            List <Map>       maps = new List <Map>();
            MobileMapPackage mmpk = null;

            if (!this.HasLayerFileSource(fileName))
            {
                LayerFileSource lfs = new LayerFileSource();
                lfs.SourceFile = fileName;
                this.LayerFileSources.Add(lfs);
                mmpk = await MobileMapPackage.OpenAsync(fileName);

                await mmpk.LoadAsync();

                foreach (Map aMap in mmpk.Maps)
                {
                    maps.Add(aMap);
                    var layerCollection = aMap.OperationalLayers.Reverse();
                    await aMap.LoadAsync();

                    Trace.WriteLine("Map = " + aMap.ToString());
                    foreach (var layer in layerCollection)
                    {
                        Layer lyr = layer.Clone();
                        lyr.IsVisible = layer.IsVisible;
                        //if (layer.Opacity == 1)
                        //    layer.Opacity = .55;
                        lyr.Opacity = layer.Opacity;
                        await lyr.LoadAsync();

                        if (lyr is FeatureLayer)
                        {
                            TesterLayer             testLayer    = new TesterLayer();
                            FeatureLayer            featLyr      = lyr as FeatureLayer;
                            GeodatabaseFeatureTable featureTable = featLyr.FeatureTable as GeodatabaseFeatureTable;
                            testLayer.FeatureTable = featureTable;
                            testLayer.FeatureLayer = featLyr;
                            lfs.Children.Add(testLayer);
                            ((FeatureLayer)lyr).LabelsEnabled        = true;
                            ((FeatureLayer)lyr).DefinitionExpression = ((FeatureLayer)layer).DefinitionExpression;
                        }
                        else if (lyr is GroupLayer)
                        {
                            SetupLayersUnderGroupLayer((GroupLayer)lyr, (GroupLayer)layer, lfs);
                        }

                        this.Map.OperationalLayers.Add(lyr);
                    }
                }
            }

            return(mmpk);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Copies the definition expressions from any feature layers under the source layer to the matching feature layers under the target layer.
        /// </summary>
        /// <param name="targetLayer">the target group layer</param>
        /// <param name="sourceLayer">the source group layer</param>
        private static void SetupLayersUnderGroupLayer(GroupLayer targetLayer, GroupLayer sourceLayer, LayerFileSource lfs)
        {
            Dictionary <string, string> defExprs = new Dictionary <string, string>();

            //
            // Collect all definition expressions.
            //
            foreach (Layer srcChildLayer in sourceLayer.Layers)
            {
                if (srcChildLayer is FeatureLayer)
                {
                    TesterLayer testLayer = new TesterLayer();
                    testLayer.FeatureLayer = srcChildLayer as FeatureLayer;
                    GeodatabaseFeatureTable featureTable = testLayer.FeatureLayer.FeatureTable as GeodatabaseFeatureTable;
                    testLayer.FeatureTable = featureTable;
                    lfs.Children.Add(testLayer);
                    FeatureLayer srcLayer = (FeatureLayer)srcChildLayer;
                    string       defExpr  = srcLayer.DefinitionExpression;

                    if (!string.IsNullOrEmpty(defExpr))
                    {
                        defExprs[srcLayer.Name] = defExpr;
                    }
                }
            }

            //
            // Apply all definition expressions.  Cache them as derived.
            //
            foreach (Layer tgtChildLayer in targetLayer.Layers)
            {
                if (tgtChildLayer is FeatureLayer)
                {
                    TesterLayer testLayer = new TesterLayer();
                    testLayer.FeatureLayer = tgtChildLayer as FeatureLayer;
                    GeodatabaseFeatureTable featureTable = testLayer.FeatureLayer.FeatureTable as GeodatabaseFeatureTable;
                    testLayer.FeatureTable = featureTable;
                    lfs.Children.Add(testLayer);
                    FeatureLayer tgtLayer = (FeatureLayer)tgtChildLayer;
                    tgtLayer.LabelsEnabled = true;

                    // This will apply the mapservice name to the feature layer under the group layers so that
                    // the results from this layer will be under the same map service or else it will be in a different set
                    // under a system generated hashcode for this layer.
                    tgtLayer.Id = targetLayer.Id;

                    if (defExprs.ContainsKey(tgtLayer.Name))
                    {
                        tgtLayer.DefinitionExpression = defExprs[tgtLayer.Name];
                    }
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Adds a SQLite geodatabase to the list of layers.
        /// </summary>
        /// <param name="pathToGeodatabase">the file to be loaded</param>
        /// <returns>simply a marker indicating that things completed (true all good, false not all good)</returns>
        public async Task <bool> AddSQLiteGeodatabaseAsync(string pathToGeodatabase)
        {
            bool allGood = true;

            if (!this.HasLayerFileSource(pathToGeodatabase))
            {
                LayerFileSource lfs = new LayerFileSource();
                lfs.SourceFile = pathToGeodatabase;
                this.LayerFileSources.Add(lfs);
                Geodatabase gdb = await Geodatabase.OpenAsync(pathToGeodatabase);

                //
                // Store the test layers.
                //
                foreach (GeodatabaseFeatureTable gft in gdb.GeodatabaseFeatureTables)
                {
                    TesterLayer testLayer = new TesterLayer();
                    testLayer.FeatureTable = gft;
                    gft.PropertyChanged   += GeodbFeatTab_PropertyChanged;
                    lfs.Children.Add(testLayer);
                }

                //
                // Now load them all.
                //
                foreach (TesterLayer tl in lfs.Children)
                {
                    GeodatabaseFeatureTable gtab = tl.FeatureTable;

                    try
                    {
                        await gtab.LoadAsync();

                        FeatureLayer fLayer = new FeatureLayer(gtab);
                        fLayer.PropertyChanged += FeatureLayer_PropertyChanged;
                        await fLayer.LoadAsync();

                        fLayer.LabelsEnabled = true;
                        this.Map.OperationalLayers.Add(fLayer);
                        tl.FeatureLayer = fLayer;
                    }
                    catch (Exception exc)
                    {
                        tl.LayerLoadException = exc;
                        allGood     = false;
                        tl.LoadDone = true;
                    }
                }
            }

            return(allGood);
        }
Exemplo n.º 15
0
        private async void HandleGenerationStatusChange(GenerateGeodatabaseJob job)
        {
            JobStatus status = job.Status;

            // Job が成功したら作成した ローカル ジオデータベース をマップに追加する
            if (status == JobStatus.Succeeded)
            {
                // 既存のレイヤーをクリア
                //myMapView.Map.OperationalLayers.Clear();
                myMapView.Map.OperationalLayers.RemoveAt(0);

                // 新しいローカル ジオデータベース を取得
                _resultGdb = await job.GetResultAsync();

                mGdbFeatureTable = _resultGdb.GeodatabaseFeatureTables.FirstOrDefault();

                // テーブから新しいフィーチャ レイヤを作成する
                FeatureLayer layer = new FeatureLayer(mGdbFeatureTable);

                // 新しいレイヤーをマップに追加する
                myMapView.Map.OperationalLayers.Add(layer);

                // 編集機能を有効にする
                _readyForEdits = EditState.Ready;
            }

            // ジオデータベースの作成ジョブに失敗した時
            if (status == JobStatus.Failed)
            {
                // エラーメッセージの作成
                string message = "ジオデータベースの作成に失敗";

                // エラーメッセージを表示する(存在する場合)
                if (job.Error != null)
                {
                    message += ": " + job.Error.Message;
                }
                else
                {
                    // エラーがなければ、ジョブからのメッセージを表示する
                    foreach (JobMessage m in job.Messages)
                    {
                        // JobMessage からテキストを取得し、出力文字列に追加します
                        message += "\n" + m.Message;
                    }
                }

                // メッセージを表示する
                ShowStatusMessage(message);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Executes ViewModel initialization logic. Called when ViewModel is created from base view model.
        /// </summary>
        protected override async Task InitializeAsync()
        {
            // Create map with layers
            Map = new Map()
            {
                InitialExtent = new Envelope(-14161146.113642, 3137996.40676956, -7626168.31478212, 6574986.2928574)
            };

            // Basemap layer from ArcGIS Online hosted service
            var basemap = new ArcGISLocalTiledLayer()
            {
                ID          = "Basemap",
                DisplayName = "Basemap",
                Path        = @"../../../../Data/TileCaches/Topographic.tpk"
            };

            // Initialize layer in Try - Catch
            Exception exceptionToHandle = null;

            try
            {
                await basemap.InitializeAsync();

                Map.Layers.Add(basemap);

                // Open geodatbase and find States feature table
                var geodatabase = await Geodatabase.OpenAsync(@"../../../../Data/Databases/usa.geodatabase");

                _featureTable = geodatabase.FeatureTables.First(x => x.Name == "States");

                // Create graphics layer for start and endpoints
                CreateGraphicsLayers();
                IsInitialized = true;
            }
            catch (Exception exception)
            {
                // Exception is thrown ie if layer url is not found - ie. {"Error code '400' : 'Invalid URL'"}
                exceptionToHandle = exception;
            }

            if (exceptionToHandle != null)
            {
                // Initialization failed, show message and return
                await MessageService.Instance.ShowMessage(string.Format(
                                                              "Could not create basemap. Error = {0}", exceptionToHandle.ToString()),
                                                          "An error occured");

                return;
            }
        }
Exemplo n.º 17
0
        // Function that loads the two point tables from the local geodatabase and displays them as feature layers
        private async void LoadLocalGeodatabaseTables()
        {
            if (_localGeodatabase == null)
            {
                return;
            }

            // Read the geodatabase tables and add them as layers
            foreach (GeodatabaseFeatureTable table in _localGeodatabase.GeodatabaseFeatureTables)
            {
                try
                {
                    // Load the table so the TableName can be read
                    await table.LoadAsync();

                    // Store a reference to the Birds table
                    if (table.TableName.ToLower().Contains("birds"))
                    {
                        _birdTable = table;
                    }

                    // Store a reference to the Marine table
                    if (table.TableName.ToLower().Contains("marine"))
                    {
                        _marineTable = table;
                    }

                    // Create a new feature layer to show the table in the map
                    FeatureLayer layer = new FeatureLayer(table);
                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => MyMapView.Map.OperationalLayers.Add(layer));
                }
                catch (Exception e)
                {
                    await new MessageDialog(e.ToString(), "Error").ShowAsync();
                }
            }

            // Handle the transaction status changed event
            _localGeodatabase.TransactionStatusChanged += GdbTransactionStatusChanged;

            // Zoom the map view to the extent of the generated local datasets
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                MyMapView.SetViewpoint(new Viewpoint(_marineTable.Extent));
                StartEditingButton.IsEnabled = true;
            });
        }
        // Function that loads the two point tables from the local geodatabase and displays them as feature layers
        private async void LoadLocalGeodatabaseTables()
        {
            if (_localGeodatabase == null)
            {
                return;
            }

            // Read the geodatabase tables and add them as layers
            foreach (GeodatabaseFeatureTable table in _localGeodatabase.GeodatabaseFeatureTables)
            {
                try
                {
                    // Load the table so the TableName can be read
                    await table.LoadAsync();

                    // Store a reference to the Birds table
                    if (table.TableName.ToLower().Contains("birds"))
                    {
                        _birdTable = table;
                    }

                    // Store a reference to the Marine table
                    if (table.TableName.ToLower().Contains("marine"))
                    {
                        _marineTable = table;
                    }

                    // Create a new feature layer to show the table in the map
                    FeatureLayer layer = new FeatureLayer(table);
                    Device.BeginInvokeOnMainThread(() => MyMapView.Map.OperationalLayers.Add(layer));
                }
                catch (Exception e)
                {
                    await((Page)Parent).DisplayAlert("Error", e.ToString(), "OK");
                }
            }

            // Handle the transaction status changed event
            _localGeodatabase.TransactionStatusChanged += GdbTransactionStatusChanged;

            // Zoom the map view to the extent of the generated local datasets
            Device.BeginInvokeOnMainThread(() =>
            {
                MyMapView.SetViewpoint(new Viewpoint(_marineTable.Extent));
                StartEditingButton.IsEnabled = true;
            });
        }
        // Function that loads the two point tables from the local geodatabase and displays them as feature layers
        private async void LoadLocalGeodatabaseTables()
        {
            if (_localGeodatabase == null)
            {
                return;
            }

            // Read the geodatabase tables and add them as layers
            foreach (GeodatabaseFeatureTable table in _localGeodatabase.GeodatabaseFeatureTables)
            {
                try
                {
                    // Load the table so the TableName can be read
                    await table.LoadAsync();

                    // Store a reference to the Birds table
                    if (table.TableName.ToLower().Contains("birds"))
                    {
                        _birdTable = table;
                    }

                    // Store a reference to the Marine table
                    if (table.TableName.ToLower().Contains("marine"))
                    {
                        _marineTable = table;
                    }

                    // Create a new feature layer to show the table in the map
                    FeatureLayer layer = new FeatureLayer(table);
                    RunOnUiThread(() => _mapView.Map.OperationalLayers.Add(layer));
                }
                catch (Exception e)
                {
                    new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
                }
            }

            // Handle the transaction status changed event
            _localGeodatabase.TransactionStatusChanged += GdbTransactionStatusChanged;

            // Zoom the map view to the extent of the generated local datasets
            RunOnUiThread(() =>
            {
                _mapView.SetViewpoint(new Viewpoint(_marineTable.Extent));
                _startEditingButton.Enabled = true;
            });
        }
Exemplo n.º 20
0
        // Function that loads the two point tables from the local geodatabase and displays them as feature layers.
        private async Task LoadLocalGeodatabaseTables()
        {
            if (_localGeodatabase == null)
            {
                return;
            }

            // Read the geodatabase tables and add them as layers.
            foreach (GeodatabaseFeatureTable table in _localGeodatabase.GeodatabaseFeatureTables)
            {
                try
                {
                    // Load the table so the TableName can be read.
                    await table.LoadAsync();

                    // Store a reference to the Birds table.
                    if (table.TableName.ToLower().Contains("birds"))
                    {
                        _birdTable = table;
                    }

                    // Store a reference to the Marine table.
                    if (table.TableName.ToLower().Contains("marine"))
                    {
                        _marineTable = table;
                    }

                    // Create a new feature layer to show the table in the map.
                    FeatureLayer layer = new FeatureLayer(table);
                    InvokeOnMainThread(() => _mapView.Map.OperationalLayers.Add(layer));
                }
                catch (Exception e)
                {
                    new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
                }
            }

            // Handle the transaction status changed event.
            _localGeodatabase.TransactionStatusChanged += GdbTransactionStatusChanged;

            // Zoom the map view to the extent of the generated local datasets.
            InvokeOnMainThread(() =>
            {
                _mapView.SetViewpoint(new Viewpoint(_marineTable.Extent));
                _transactionButton.Enabled = true;
            });
        }
Exemplo n.º 21
0
 public static LayerDef GenerateDefaultLayerDef(GeodatabaseFeatureTable table)
 {
     IS3.Core.Geometry.GeometryType geomType = IS3.Core.Geometry.GeometryType.Point;
     if (table.GeometryType == GeometryType.Point)
     {
         geomType = IS3.Core.Geometry.GeometryType.Point;
     }
     else if (table.GeometryType == GeometryType.Polyline)
     {
         geomType = IS3.Core.Geometry.GeometryType.Polyline;
     }
     else if (table.GeometryType == GeometryType.Polygon)
     {
         geomType = IS3.Core.Geometry.GeometryType.Polygon;
     }
     return(GenerateDefaultLayerDef(table.Name, geomType));
 }
Exemplo n.º 22
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;
            }
        }
Exemplo n.º 23
0
        public async void Search(string searchString)
        {
            FeatureLayer            featureLayer = this.mapView.Map.Layers[1] as FeatureLayer;
            GeodatabaseFeatureTable table        = featureLayer.FeatureTable as GeodatabaseFeatureTable;

            // Define an attribute query
            var filter = new Esri.ArcGISRuntime.Data.QueryFilter();

            filter.WhereClause = "POST_ID = '" + searchString + "'";     // 666-13080

            // Execute the query and await results
            IEnumerable <Feature> features = await table.QueryAsync(filter);

            foreach (Feature feature in features)
            {
                string address = feature.Attributes["STREETNAME"] as string;
                System.Diagnostics.Debug.WriteLine("Address: " + address);
            }
        }
Exemplo n.º 24
0
        private async void readGeoDatabase()
        {
            geodatabase = await Geodatabase.OpenAsync(mGeodatabasePath);

            if (geodatabase.GeodatabaseFeatureTables.Count > 0)
            {
                // データベース内の最初のテーブルを取得する
                mGdbFeatureTable = geodatabase.GeodatabaseFeatureTables.FirstOrDefault();

                await mGdbFeatureTable.LoadAsync();

                if (mGdbFeatureTable.LoadStatus == LoadStatus.Loaded)
                {
                    myMap.OperationalLayers.RemoveAt(0);

                    mFeatureLayer = new FeatureLayer(mGdbFeatureTable);

                    myMap.OperationalLayers.Add(mFeatureLayer);
                }
            }
        }
        /// <summary>
        /// マップビュー読み込み時のイベント ハンドラ
        /// </summary>
        private async void mapView_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                //ローカル ジオデータベース(Runtime コンテンツ)のフィーチャ テーブルを読み込み
                var gdb = await Geodatabase.OpenAsync(GDB_PATH);
                _gdbTable = gdb.FeatureTables.FirstOrDefault();

                //フィーチャ テーブルに設定されたレンダラ―(シンボル情報)を取得
                _graphicsLayer = new GraphicsLayer() { RenderingMode = GraphicsRenderingMode.Static };
                _graphicsLayer.Renderer = _gdbTable.ServiceInfo.DrawingInfo.Renderer;

                //フィーチャを表示
                var features = await _gdbTable.QueryAsync(new QueryFilter() { WhereClause = GetFilterTest() });
                _graphicsLayer.GraphicsSource = features.Select(f => new Graphic(f.Geometry));

                //マップにグラフィックスレイヤーを追加
                mapView.Map.Layers.Add(_graphicsLayer);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("フィーチャ レイヤーの作成に失敗しました: {0}", ex.Message));
            }
        }
Exemplo n.º 26
0
        private void GeodbFeatTab_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            GeodatabaseFeatureTable featTab = (GeodatabaseFeatureTable)sender;

            Trace.WriteLine("Geodatabase property changed = " + e.PropertyName + " against " + featTab.TableName);
        }
        private async void GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            try
            {
                // Disregard if not ready for edits.
                if (_readyForEdits == EditState.NotReady)
                {
                    return;
                }

                // If an edit is in process, finish it.
                if (_readyForEdits == EditState.Editing)
                {
                    // Hold a list of any selected features.
                    List <Feature> selectedFeatures = new List <Feature>();

                    // Get all selected features then clear selection.
                    foreach (FeatureLayer layer in myMapView.Map.OperationalLayers)
                    {
                        // Get the selected features.
                        FeatureQueryResult layerFeatures = await layer.GetSelectedFeaturesAsync();

                        // FeatureQueryResult implements IEnumerable, so it can be treated as a collection of features.
                        selectedFeatures.AddRange(layerFeatures);

                        // Clear the selection.
                        layer.ClearSelection();
                    }

                    // Update all selected features' geometry.
                    foreach (Feature feature in selectedFeatures)
                    {
                        // Get a reference to the correct feature table for the feature.
                        GeodatabaseFeatureTable table = (GeodatabaseFeatureTable)feature.FeatureTable;

                        // Ensure the geometry type of the table is point.
                        if (table.GeometryType != GeometryType.Point)
                        {
                            continue;
                        }

                        // Set the new geometry.
                        feature.Geometry = e.Location;

                        // Update the feature in the table.
                        await table.UpdateFeatureAsync(feature);
                    }

                    // Update the edit state.
                    _readyForEdits = EditState.Ready;

                    // Enable the sync button.
                    mySyncButton.IsEnabled = true;

                    // Update the help label.
                    MyHelpLabel.Text = "4. Click 'Synchronize' or keep editing";
                }
                // Otherwise, start an edit.
                else
                {
                    // Define a tolerance for use with identifying the feature.
                    double tolerance = 15 * myMapView.UnitsPerPixel;

                    // Define the selection envelope.
                    Envelope selectionEnvelope = new Envelope(e.Location.X - tolerance, e.Location.Y - tolerance, e.Location.X + tolerance, e.Location.Y + tolerance);

                    // Define query parameters for feature selection.
                    QueryParameters query = new QueryParameters()
                    {
                        Geometry = selectionEnvelope
                    };

                    // Select the feature in all applicable tables.
                    foreach (FeatureLayer layer in myMapView.Map.OperationalLayers)
                    {
                        await layer.SelectFeaturesAsync(query, SelectionMode.New);
                    }

                    // Set the edit state.
                    _readyForEdits = EditState.Editing;

                    // Update the help label.
                    MyHelpLabel.Text = "3. Tap on the map to move the point";
                }
            }
            catch (Exception ex)
            {
                await((Page)Parent).DisplayAlert("Error", ex.ToString(), "OK");
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Creates a frequency analysis file for the specified table.
        /// </summary>
        /// <param name="outputFile">the file to which to write the analysis</param>
        /// <param name="table">the table to analyse</param>
        /// <returns>did things go well?</returns>
        public async Task <bool> RunFrequencyAnalysis(string outputFile, GeodatabaseFeatureTable table)
        {
            bool allGood   = true;
            long totalRecs = table.NumberOfFeatures;
            Dictionary <string, Dictionary <string, uint> > freqs = new Dictionary <string, Dictionary <string, uint> >();
            string whereClause           = "1=1";
            string orderingName          = null;
            long   lastOID               = 0;
            int    lastBatchCount        = -1;
            long   totalRecordsProcessed = 0;
            int    recordsPerBatch       = 10000;

            foreach (Field aField in table.Fields)
            {
                if (aField.FieldType == FieldType.OID)
                {
                    orderingName = aField.Name;
                    whereClause  = aField.Name + " > " + lastOID + " order by " + aField.Name;
                    break;
                }
            }

            try
            {
                while (lastBatchCount != 0)
                {
                    QueryParameters queryParams = new QueryParameters();
                    queryParams.ReturnGeometry = true;
                    lastBatchCount             = 0;

                    if (orderingName == null)
                    {
                        queryParams.WhereClause = "1=1";
                    }
                    else
                    {
                        queryParams.WhereClause = orderingName + " > " + lastOID + " order by " + orderingName;
                    }

                    FeatureQueryResult result = await table.QueryFeaturesAsync(queryParams);

                    IEnumerator <Feature> features = result.GetEnumerator();
                    object attValue       = null;
                    string attStringValue = null;

                    //
                    // Collect the frequencies.
                    //
                    while (features.MoveNext())
                    {
                        Feature aFeature = features.Current;
                        totalRecordsProcessed++;
                        lastBatchCount++;

                        foreach (string attName in aFeature.Attributes.Keys)
                        {
                            attValue = aFeature.Attributes[attName];

                            if (attValue == null)
                            {
                                attStringValue = "";
                            }
                            else
                            {
                                attStringValue = attValue.ToString();
                            }

                            this.StoreFrequency(attName, attStringValue, freqs);

                            if (orderingName.Equals(attName))
                            {
                                lastOID = (long)attValue;
                            }
                        }

                        if (totalRecordsProcessed % 2500 == 0)
                        {
                            Trace.WriteLine("Processed " + totalRecordsProcessed + " out of " + table.NumberOfFeatures);
                        }

                        if (lastBatchCount == recordsPerBatch)
                        {
                            features.Dispose();
                            break;
                        }
                    }
                }

                //
                // Write out the frequencies.
                //
                using (StreamWriter writer = new StreamWriter(outputFile))
                {
                    foreach (string attributeName in freqs.Keys)
                    {
                        Dictionary <string, uint> attributeFreqs = freqs[attributeName];

                        if (attributeFreqs.Count > 200)
                        {
                            writer.Write("\"");
                            writer.Write(attributeName);
                            writer.Write("\"");
                            writer.Write(",");
                            writer.Write("\"");
                            writer.Write("<MANY VALUES>");
                            writer.Write("\"");
                            writer.Write(",");
                            writer.Write(table.NumberOfFeatures);
                            writer.Write("\n");
                        }
                        else
                        {
                            foreach (string attributeValue in attributeFreqs.Keys)
                            {
                                uint numVals = attributeFreqs[attributeValue];
                                writer.Write("\"");
                                writer.Write(attributeName);
                                writer.Write("\"");
                                writer.Write(",");
                                writer.Write("\"");
                                writer.Write(attributeValue);
                                writer.Write("\"");
                                writer.Write(",");
                                writer.Write(numVals);
                                writer.Write("\n");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                allGood = false;
                string excString = "=====================\n";
                excString        = excString + e.Message + "\n";
                excString        = excString + e.StackTrace + "\n";
                this.LoggingText = excString;
            }

            return(allGood);
        }
		/// <summary>
		/// Executes ViewModel initialization logic. Called when ViewModel is created from base view model. 
		/// </summary>
		protected override async Task InitializeAsync()
		{
			// Create map with layers
			Map = new Map()
				{
					InitialExtent = new Envelope(-14161146.113642, 3137996.40676956, -7626168.31478212, 6574986.2928574)
				};		

			// Basemap layer from ArcGIS Online hosted service
			var basemap = new ArcGISLocalTiledLayer()
			{
				ID = "Basemap",
				DisplayName = "Basemap",
				Path = @"../../../../Data/TileCaches/Topographic.tpk"
			};

			// Initialize layer in Try - Catch 
			Exception exceptionToHandle = null;
			try
			{
				await basemap.InitializeAsync();
				Map.Layers.Add(basemap);

				// Open geodatbase and find States feature table
				var geodatabase = await Geodatabase.OpenAsync(@"../../../../Data/Databases/usa.geodatabase");
				_featureTable = geodatabase.FeatureTables.First(x => x.Name == "States");

				// Create graphics layer for start and endpoints
				CreateGraphicsLayers();
				IsInitialized = true;
			}
			catch (Exception exception)
			{
				// Exception is thrown ie if layer url is not found - ie. {"Error code '400' : 'Invalid URL'"} 
				exceptionToHandle = exception;
			}

			if (exceptionToHandle != null)
			{
				// Initialization failed, show message and return
				await MessageService.Instance.ShowMessage(string.Format(
					"Could not create basemap. Error = {0}", exceptionToHandle.ToString()),
					"An error occured");
				return;
			}
		}
Exemplo n.º 30
0
        private async void GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            try
            {
                // Disregard if not ready for edits.
                if (_readyForEdits == EditState.NotReady)
                {
                    return;
                }

                // If an edit is in process, finish it.
                if (_readyForEdits == EditState.Editing)
                {
                    // Hold a list of any selected features.
                    List <Feature> selectedFeatures = new List <Feature>();

                    // Get all selected features then clear selection.
                    foreach (FeatureLayer layer in MyMapView.Map.OperationalLayers)
                    {
                        // Get the selected features.
                        FeatureQueryResult layerFeatures = await layer.GetSelectedFeaturesAsync();

                        // FeatureQueryResult implements IEnumerable, so it can be treated as a collection of features.
                        selectedFeatures.AddRange(layerFeatures);

                        // Clear the selection.
                        layer.ClearSelection();
                    }

                    // Update all selected feature geometry.
                    foreach (Feature feature in selectedFeatures)
                    {
                        // Get a reference to the correct feature table for the feature.
                        GeodatabaseFeatureTable table = (GeodatabaseFeatureTable)feature.FeatureTable;

                        // Ensure the geometry type of the table is point.
                        if (table.GeometryType != GeometryType.Point)
                        {
                            continue;
                        }

                        // Set the new geometry.
                        feature.Geometry = e.Location;

                        try
                        {
                            // Update the feature in the table.
                            await table.UpdateFeatureAsync(feature);
                        }
                        catch (Esri.ArcGISRuntime.ArcGISException)
                        {
                            ShowStatusMessage("Feature must be within extent of geodatabase.");
                        }
                    }

                    // Update the edit state.
                    _readyForEdits = EditState.Ready;

                    // Enable the sync button.
                    SyncButton.IsEnabled = true;

                    // Update the help label.
                    MyHelpLabel.Text = "4. Click 'Sync' or edit more features";
                }
                // Otherwise, start an edit.
                else
                {
                    // Define a tolerance for use with identifying the feature.
                    double tolerance = 15 * MyMapView.UnitsPerPixel;

                    // Define the selection envelope.
                    Envelope selectionEnvelope = new Envelope(e.Location.X - tolerance, e.Location.Y - tolerance, e.Location.X + tolerance, e.Location.Y + tolerance);

                    // Define query parameters for feature selection.
                    QueryParameters query = new QueryParameters()
                    {
                        Geometry = selectionEnvelope
                    };

                    // Track whether any selections were made.
                    bool selectedFeature = false;

                    // Select the feature in all applicable tables.
                    foreach (FeatureLayer layer in MyMapView.Map.OperationalLayers)
                    {
                        FeatureQueryResult res = await layer.SelectFeaturesAsync(query, SelectionMode.New);

                        selectedFeature = selectedFeature || res.Any();
                    }

                    // Only update state if a feature was selected.
                    if (selectedFeature)
                    {
                        // Set the edit state.
                        _readyForEdits = EditState.Editing;

                        // Update the help label.
                        MyHelpLabel.Text = "3. Tap on the map to move the point";
                    }
                }
            }
            catch (Exception ex)
            {
                ShowStatusMessage(ex.ToString());
            }
        }
        private void GetOutputLocations(GeodatabaseFeatureTable table, FileInfo file, out string copyToFolder, out string copyToFile)
        {
            copyToFolder = Path.Combine(_attachmentOutFolder, table.TableName);

            copyToFile = Path.Combine(copyToFolder, file.Name);
        }
        private async void GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Disregard if not ready for edits
            if (_readyForEdits == EditState.NotReady)
            {
                return;
            }

            // If an edit is in process, finish it
            if (_readyForEdits == EditState.Editing)
            {
                // Hold a list of any selected features
                List <Feature> selectedFeatures = new List <Feature>();

                // Get all selected features then clear selection
                foreach (FeatureLayer layer in myMapView.Map.OperationalLayers)
                {
                    // Get the selected features
                    FeatureQueryResult layerFeatures = await layer.GetSelectedFeaturesAsync();

                    // FeatureQueryResult implements IEnumerable, so it can be treated as a collection of features
                    selectedFeatures.AddRange(layerFeatures);

                    // Clear the selection
                    layer.ClearSelection();
                }

                // Update all selected features' geometry
                foreach (Feature feature in selectedFeatures)
                {
                    // Get a reference to the correct feature table for the feature
                    GeodatabaseFeatureTable table = feature.FeatureTable as GeodatabaseFeatureTable;

                    // Ensure the geometry type of the table is point
                    if (table.GeometryType != GeometryType.Point)
                    {
                        continue;
                    }

                    // Set the new geometry
                    feature.Geometry = e.Location;

                    // Update the feature in the table
                    await table.UpdateFeatureAsync(feature);
                }

                // Update the edit state
                _readyForEdits = EditState.Ready;

                // Enable the sync button
                mySyncButton.Enabled = true;
            }
            // Otherwise, start an edit
            else
            {
                // Define a tolerance for use with identifying the feature
                double tolerance = 15 * myMapView.UnitsPerPixel;

                // Define the selection envelope
                Envelope selectionEnvelope = new Envelope(e.Location.X - tolerance, e.Location.Y - tolerance, e.Location.X + tolerance, e.Location.Y + tolerance);

                // Define query parameters for feature selection
                QueryParameters query = new QueryParameters()
                {
                    Geometry = selectionEnvelope
                };

                // Select the feature in all applicable tables
                foreach (FeatureLayer layer in myMapView.Map.OperationalLayers)
                {
                    await layer.SelectFeaturesAsync(query, SelectionMode.New);
                }

                // Set the edit state
                _readyForEdits = EditState.Editing;
            }
        }