Example #1
0
        public static async Task <List <object> > GetAttributes(string url, string whereClause = "", string[] fieldNames = null)
        {
            if (fieldNames == null)
            {
                return(null);
            }

            var attributes = new List <object>();
            var table      = new ServiceFeatureTable(new Uri(url));
            await table.LoadAsync();

            if (table.GeometryType != Esri.ArcGISRuntime.Geometry.GeometryType.Polygon)
            {
                return(null);
            }

            var queryParams = new QueryParameters();

            queryParams.WhereClause = whereClause;
            var count = await table.QueryFeatureCountAsync(queryParams);

            var queryFeatureResults = await table.QueryFeaturesAsync(queryParams);

            var resultingFeature = queryFeatureResults.FirstOrDefault();

            foreach (var fieldName in fieldNames)
            {
                attributes.Add(resultingFeature.GetAttributeValue(fieldName));
            }

            return(attributes);
        }
Example #2
0
        private async void Initialize()
        {
            // Create a tile cache and load it with the SanFrancisco streets tpk.
            TileCache tileCache = new TileCache(DataManager.GetDataFolder("3f1bbf0ec70b409a975f5c91f363fe7d", "SanFrancisco.tpk"));

            // Create the corresponding layer based on the tile cache.
            ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache);

            // Create the basemap based on the tile cache.
            Basemap sfBasemap = new Basemap(tileLayer);

            // Create the map with the tile-based basemap.
            Map myMap = new Map(sfBasemap);

            // Assign the map to the MapView.
            MyMapView.Map = myMap;

            // Create a new symbol for the extent graphic.
            SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2);

            // Create graphics overlay for the extent graphic and apply a renderer.
            GraphicsOverlay extentOverlay = new GraphicsOverlay
            {
                Renderer = new SimpleRenderer(lineSymbol)
            };

            // Add graphics overlay to the map view.
            MyMapView.GraphicsOverlays.Add(extentOverlay);

            // Set up an event handler for when the viewpoint (extent) changes.
            MyMapView.ViewpointChanged += MapViewExtentChanged;

            // Create a task for generating a geodatabase (GeodatabaseSyncTask).
            _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri);

            // Add all layers from the service to the map.
            foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos)
            {
                // Get the URL for this particular layer.
                Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id);

                // Create the ServiceFeatureTable.
                ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri);

                // Wait for the table to load.
                await onlineTable.LoadAsync();

                // Add the layer to the map's operational layers if load succeeds.
                if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
                {
                    myMap.OperationalLayers.Add(new FeatureLayer(onlineTable));
                }
            }

            // Update the extent graphic so that it is valid before user interaction.
            UpdateMapExtent();

            // Enable the generate button now that the sample is ready.
            MyGenerateButton.IsEnabled = true;
        }
        /// <summary>
        /// Requests for features whose attributes will be displayed in <see cref="UI.FeatureDataField"/>
        /// </summary>
        /// <returns>A task that represents the asynchronous loading of features. </returns>
        private async Task LoadFeaturesAsync()
        {
            string error = null;

            try
            {
                var table = new ServiceFeatureTable(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessmentStatePlane/FeatureServer/0"));
                table.FeatureRequestMode = FeatureRequestMode.ManualCache;
                await table.LoadAsync();

                var queryParameters = new QueryParameters()
                {
                    WhereClause = "incidentid <> ''",
                    MaxFeatures = 100
                };
                // Request for the same fields defined in the ListView.ItemTemplate.
                var outFields = new string[] { "objectid", "incidentid", "typdamage", "habitable", "predisval", "inspdate", "lastupdate" };
                var features  = await table.PopulateFromServiceAsync(queryParameters, true, outFields);

                grid.ItemsSource = features.ToList();
            }
            catch (Exception exception)
            {
                error = exception.Message;
            }
            if (!string.IsNullOrEmpty(error))
            {
                await new MessageDialog($"Error occured : {error}", "Sample error").ShowAsync();
            }
        }
Example #4
0
        public static async Task <List <Esri.ArcGISRuntime.Geometry.Geometry> > GetGeometries(string url, string whereClause = "objectid > 0")
        {
            var geometries = new List <Esri.ArcGISRuntime.Geometry.Geometry>();

            try
            {
                var table = new ServiceFeatureTable(new Uri(url));
                await table.LoadAsync();

                var queryParams = new QueryParameters();
                queryParams.WhereClause = whereClause;
                var count = await table.QueryFeatureCountAsync(queryParams);

                var queryFeatureResults = await table.QueryFeaturesAsync(queryParams);

                foreach (var result in queryFeatureResults)
                {
                    geometries.Add(result.Geometry);
                }
            }
            catch (Exception)
            {
            }

            return(geometries);
        }
        private async void Initialize()
        {
            // Create a tile cache and load it with the SanFrancisco streets tpk
            TileCache tileCache = new TileCache(GetTpkPath());

            // Create the corresponding layer based on the tile cache
            ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache);

            // Create the basemap based on the tile cache
            Basemap sfBasemap = new Basemap(tileLayer);

            // Create the map with the tile-based basemap
            Map myMap = new Map(sfBasemap);

            // Assign the map to the MapView
            myMapView.Map = myMap;

            // Create a new symbol for the extent graphic
            SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2);

            // Create graphics overlay for the extent graphic and apply a renderer
            GraphicsOverlay extentOverlay = new GraphicsOverlay();

            extentOverlay.Renderer = new SimpleRenderer(lineSymbol);

            // Add graphics overlay to the map view
            myMapView.GraphicsOverlays.Add(extentOverlay);

            // Set up an event handler for when the viewpoint (extent) changes
            myMapView.ViewpointChanged += MapViewExtentChanged;

            // Set up event handler for mapview taps
            myMapView.GeoViewTapped += GeoViewTapped;

            // Update the local data path for the geodatabase file
            _gdbPath = GetFileStreamPath("wildfire.geodatabase").AbsolutePath;

            // Create a task for generating a geodatabase (GeodatabaseSyncTask)
            _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri);

            // Add all graphics from the service to the map
            foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos)
            {
                // Get the Uri for this particular layer
                Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id);

                // Create the ServiceFeatureTable
                ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri);

                // Wait for the table to load
                await onlineTable.LoadAsync();

                // Add the layer to the map's operational layers if load succeeds
                if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
                {
                    myMap.OperationalLayers.Add(new FeatureLayer(onlineTable));
                }
            }
        }
        private async void Initialize()
        {
            // Create a tile cache and load it with the SanFrancisco streets tpk
            TileCache _tileCache = new TileCache(GetTpkPath());

            // Create the corresponding layer based on the tile cache
            ArcGISTiledLayer _tileLayer = new ArcGISTiledLayer(_tileCache);

            // Create the basemap based on the tile cache
            Basemap _sfBasemap = new Basemap(_tileLayer);

            // Create the map with the tile-based basemap
            Map myMap = new Map(_sfBasemap);

            // Assign the map to the MapView
            MyMapView.Map = myMap;

            // Create a new symbol for the extent graphic
            SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Red, 2);

            // Create graphics overlay for the extent graphic and apply a renderer
            GraphicsOverlay extentOverlay = new GraphicsOverlay();

            extentOverlay.Renderer = new SimpleRenderer(lineSymbol);

            // Add graphics overlay to the map view
            MyMapView.GraphicsOverlays.Add(extentOverlay);

            // Set up an event handler for when the viewpoint (extent) changes
            MyMapView.ViewpointChanged += MapViewExtentChanged;

            // Create a task for generating a geodatabase (GeodatabaseSyncTask)
            _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri);

            // Add all graphics from the service to the map
            foreach (var layer in _gdbSyncTask.ServiceInfo.LayerInfos)
            {
                // Create the ServiceFeatureTable for this particular layer
                ServiceFeatureTable onlineTable = new ServiceFeatureTable(new Uri(_featureServiceUri + "/" + layer.Id));

                // Wait for the table to load
                await onlineTable.LoadAsync();

                // Add the layer to the map's operational layers if load succeeds
                if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
                {
                    myMap.OperationalLayers.Add(new FeatureLayer(onlineTable));
                }
            }

            // Update the extent graphic so that it is valid before user interaction
            UpdateMapExtent();

            // Enable the generate button now that the sample is ready
            MyGenerateButton.IsEnabled = true;
        }
Example #7
0
        public void metro_data()
        {
            /* first get stops */

            Task.Factory.StartNew(async() =>
            {
                Uri u = new System.Uri("https://services1.arcgis.com/gOY38HDnFUYPDony/ArcGIS/rest/services/la_busstops1217/FeatureServer/1");

                var agsl_stop = new ServiceFeatureTable(u);
                await agsl_stop.LoadAsync();
                this.RunOnUiThread(
                    () =>
                {
                    var stopsLayer = new Esri.ArcGISRuntime.Mapping.FeatureLayer(agsl_stop);

                    var stopmark        = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Yellow, 4f);
                    stopsLayer.Renderer = new SimpleRenderer(stopmark);

                    MySceneView.Scene.OperationalLayers.Add(stopsLayer);
                });
            });


            /* then get vehicles */

            WebClient client = new WebClient();
            var       wgs84  = MySceneView.Scene.SpatialReference;

            metro = new GraphicsOverlay();

            var pmark = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.IndianRed, 4f);

            metro.Renderer = new SimpleRenderer(pmark);
            metro.SceneProperties.SurfacePlacement = SurfacePlacement.Draped;

            Task.Factory.StartNew(async() => {
                while (true)
                {
                    string downloadString = client.DownloadString("http://api.metro.net/agencies/lametro/vehicles/");
                    MetroJSON res         = JsonConvert.DeserializeObject <MetroJSON>(downloadString);
                    metro.Graphics.Clear();
                    foreach (MetroInnerJSON vehicle in res.items)
                    {
                        var ploc  = new MapPoint(vehicle.longitude, vehicle.latitude, 0, wgs84);
                        var ptest = new Graphic(ploc);
                        metro.Graphics.Add(ptest);
                    }

                    await Task.Delay(2300);
                }
            });

            MySceneView.GraphicsOverlays.Add(metro);
        }
Example #8
0
        public static async Task <IdentifierAvailableEnum> IdentifierAvailable(string identifier)
        {
            try
            {
                await _featureTable.LoadAsync();

                var query = new QueryParameters();
                query.WhereClause = $"lower(identifier) = '{identifier}'";

                var all = await _featureTable.FeatureLayer.SelectFeaturesAsync(query, Esri.ArcGISRuntime.Mapping.SelectionMode.New);

                // if any, record returned with 'identifier' being attempted to be used
                if (all.Any())
                {
                    return(IdentifierAvailableEnum.NotAvailable);
                }
                return(IdentifierAvailableEnum.Available);
            }
            catch (ArcGISWebException)
            {
                return(IdentifierAvailableEnum.Exception);
            }
        }
Example #9
0
        private async Task CreateFeature(Image capturedImage, int healthValue)
        {
            _helpLabel.Text = "Adding feature...";

            try
            {
                // Get the geometry of the feature.
                MapPoint featurePoint = _graphicsOverlay.Graphics.First().Geometry as MapPoint;

                // Create attributes for the feature using the user selected health value.
                IEnumerable <KeyValuePair <string, object> > featureAttributes = new Dictionary <string, object>()
                {
                    { "Health", (short)healthValue }, { "Height", 3.2 }, { "Diameter", 1.2 }
                };

                // Ensure that the feature table is loaded.
                if (_featureTable.LoadStatus != Esri.ArcGISRuntime.LoadStatus.Loaded)
                {
                    await _featureTable.LoadAsync();
                }

                // Create the new feature
                ArcGISFeature newFeature = _featureTable.CreateFeature(featureAttributes, featurePoint) as ArcGISFeature;

                // Convert the Image from ARCore into a JPEG byte array.
                byte[] attachmentData = await ConvertImageToJPEG(capturedImage);

                // Add the attachment.
                // The contentType string is the MIME type for JPEG files, image/jpeg.
                await newFeature.AddAttachmentAsync("tree.jpg", "image/jpeg", attachmentData);

                // Add the newly created feature to the feature table.
                await _featureTable.AddFeatureAsync(newFeature);

                // Apply the edits to the service feature table.
                await _featureTable.ApplyEditsAsync();

                // Reset the user interface.
                _helpLabel.Text = "Tap to create a feature";
                _graphicsOverlay.Graphics.Clear();
                _addButton.Enabled = false;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                ShowMessage("Could not create feature", "Error");
            }
        }
Example #10
0
        public void metro_data()
        {
            /* first get stops */
            Task.Factory.StartNew(async() =>
            {
                Uri u = new System.Uri("https://services1.arcgis.com/gOY38HDnFUYPDony/ArcGIS/rest/services/la_busstops1217/FeatureServer/1");

                var agsl_stop = new ServiceFeatureTable(u);
                await agsl_stop.LoadAsync();
                Application.Current.Dispatcher.Invoke(
                    () =>
                {
                    var stopsLayer = new Esri.ArcGISRuntime.Mapping.FeatureLayer(agsl_stop);
                    MySceneView.Scene.OperationalLayers.Add(stopsLayer);
                });

                Debug.WriteLine("busstop: " + agsl_stop.LoadStatus);
            });

            /* then get vehicles */

            WebClient client = new WebClient();
            var       wgs84  = MySceneView.Scene.SpatialReference;

            metro = new GraphicsOverlay();
            metro.SceneProperties.SurfacePlacement = SurfacePlacement.Draped;

            Task.Factory.StartNew(async() => {
                while (true)
                {
                    string downloadString = client.DownloadString("http://api.metro.net/agencies/lametro/vehicles/");
                    dynamic res           = JsonConvert.DeserializeObject(downloadString);
                    metro.Graphics.Clear();
                    foreach (dynamic vehicle in res.items)
                    {
                        var ploc  = new MapPoint(vehicle.longitude.Value, vehicle.latitude.Value, 0, wgs84);
                        var pmark = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Colors.IndianRed, 8);
                        var ptest = new Graphic(ploc, pmark);
                        metro.Graphics.Add(ptest);
                    }

                    await Task.Delay(1000);
                }
            });

            MySceneView.GraphicsOverlays.Add(metro);
        }
Example #11
0
        private async void Initialize()
        {
            // タイル キャッシュをを読み込む
            TileCache tileCache = new TileCache(GetTpkPath());

            // タイル キャッシュレイヤーの作成
            ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache);

            // ベースマップクラスにタイル キャッシュ レイヤーを設定
            Basemap sfBasemap = new Basemap(tileLayer);

            // マップにタイル キャッシュ レイヤーのベースマップを設定
            Map myMap = new Map(sfBasemap);

            Envelope initialLocation = new Envelope(
                15539982.3500528, 4255968.158699, 15545870.466201, 4262306.70411199,
                SpatialReferences.WebMercator);

            myMap.InitialViewpoint = new Viewpoint(initialLocation);

            // MapView に作成したマップを設定
            myMapView.Map = myMap;

            // ジオデータベース ファイルのローカルデータパスを取得
            _gdbPath = GetGdbPath();

            // ジオデータベースを生成するためのタスクを作成する
            _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(FEATURELAYER_SERVICE_URL);

            // サービスから地図にフィーチャ レイヤーを追加する
            foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos)
            {
                Uri onlineTableUri = new Uri(FEATURELAYER_SERVICE_URL + "/" + layer.Id);

                // ServiceFeatureTableを作成する
                ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri);

                await onlineTable.LoadAsync();

                // ロードが成功した場合は、マップの操作レイヤーにレイヤーを追加
                if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
                {
                    myMap.OperationalLayers.Add(new FeatureLayer(onlineTable));
                }
            }
        }
Example #12
0
        private async Task Init()
        {
            // Path to the folder with classifiers models
            var jarRoot = @"C:\stanford-ner-2018-10-16";
            var classifiersDirecrory = jarRoot + @"\classifiers";

            // Loading 3 class classifier model
            _classifier = CRFClassifier.getClassifierNoExceptions(
                classifiersDirecrory + @"\english.all.3class.distsim.crf.ser.gz");

            // Define a regular expression for finding the location element
            _locationRx = new Regex(@"<LOCATION\b[^>]*>(.*?)</LOCATION>",
                                    RegexOptions.Compiled | RegexOptions.IgnoreCase);

            // Define configurations for parsing artist and listener info
            var configArtistInfoJson = @"
            {
                'artist': '//h1[contains(@class, \'view-header\')]',
                'about': '//div[contains(@class, \'bio-primary\')]',
                'more': '//div[contains(@class, \'bio-secondary\')]',
                'listeners-city': '//span[contains(@class, \'horizontal-list__item__title\')]',
                'listeners': '//span[contains(@class, \'horizontal-list__item__subtitle\')]'
            }";

            ConfigSection configArtist = StructuredDataConfig.ParseJsonString(configArtistInfoJson);

            _artistScraping = new StructuredDataExtractor(configArtist);

            // Get the hosted feature layers for editing
            ArcGISPortal portal = await ArcGISPortal.CreateAsync();

            PortalItem hometownLayerItem = await PortalItem.CreateAsync(portal, _hometownLayerId);

            PortalItem otherPointsLayerItem = await PortalItem.CreateAsync(portal, _otherPointsLayerId);

            PortalItem listenerLayerItem = await PortalItem.CreateAsync(portal, _listenerLayerId);

            _hometownTable    = new ServiceFeatureTable(hometownLayerItem, 0);
            _otherPointsTable = new ServiceFeatureTable(otherPointsLayerItem, 0);
            _listenerTable    = new ServiceFeatureTable(listenerLayerItem, 0);
            await _hometownTable.LoadAsync();

            await _otherPointsTable.LoadAsync();

            await _listenerTable.LoadAsync();
        }
        private async void Initialize()
        {
            try
            {
                // Create the map and show it in the view.
                Map newMap = new Map(Basemap.CreateLightGrayCanvas());
                _myMapView.Map = newMap;

                // Create the table containing the facilities.
                _facilitiesTable = new ServiceFeatureTable(new Uri(FacilitiesFeatureUrl));

                // Create the layer for rendering the facilities table.
                FeatureLayer facilitiesLayer = new FeatureLayer(_facilitiesTable);

                // Create a simple renderer that will display an image for each facility.
                facilitiesLayer.Renderer = new SimpleRenderer(new PictureMarkerSymbol(new Uri(IconUrl)));

                // Add the layer to the map.
                newMap.OperationalLayers.Add(facilitiesLayer);

                // Create the graphics overlay for displaying the result polygons.
                _resultOverlay = new GraphicsOverlay();

                // Add the result overlay to the view.
                _myMapView.GraphicsOverlays.Add(_resultOverlay);

                // Create a list of fill symbols for rendering the results.
                _fillSymbols = new List <SimpleFillSymbol>();
                _fillSymbols.Add(new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.Color.FromArgb(0x66, 0xFF, 0xA5, 0x00), null));
                _fillSymbols.Add(new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.Color.FromArgb(0x66, 0xFF, 0x00, 0x00), null));

                // Wait for the table to load and zoom to its extent.
                await _facilitiesTable.LoadAsync();

                await _myMapView.SetViewpointGeometryAsync(_facilitiesTable.Extent, 50);

                // Enable the button now that the sample is ready.
                _findServiceAreasButton.Enabled = true;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                ShowMessage("Error", "Error starting the sample.");
            }
        }
Example #14
0
        public MapViewModel()
        {
            // Initialize a new basemap
            _basemap = Basemap.CreateDarkGrayCanvasVector();
            var status = _basemap.LoadStatus;

            switch (status)
            {
            case LoadStatus.Loaded:
                // Create a map
                Map = new Map(_basemap);

                // Create and load the countries layer
                _countries = CreateWorldCountriesTable();
                _countries.LoadAsync();

                // Create the graphics overlays
                _geonamesOverlay  = CreateGeonamesOverlay();
                _countriesOverlay = CreateCountriesOverlay();

                // Create a timer
                _timer          = new DispatcherTimer(DispatcherPriority.ApplicationIdle);
                _timer.Interval = new TimeSpan(0, 0, 0, 0, 500);
                _timer.Tick    += Animate;

                // Add it to the map view
                Overlays = new GraphicsOverlayCollection();
                Overlays.Add(_geonamesOverlay);
                Overlays.Add(_countriesOverlay);
                break;

            default:
                // TODO: Error handling
                break;
            }

            // Update the commands
            var geonamesOverlay = new GeonamesOverlay(_geonamesOverlay, _countries, _countriesOverlay);

            LoadGeonamesFileCommand            = new LoadGeonamesFileCommand(geonamesOverlay);
            CalculateGeonamesStatisticsCommand = new CalculateGeonamesStatisticsCommand(geonamesOverlay);
        }
Example #15
0
        private async Task CreateFeature(int healthValue)
        {
            HelpLabel.Text = "Adding feature...";

            try
            {
                // Get the geometry of the feature.
                MapPoint featurePoint = _graphicsOverlay.Graphics.First().Geometry as MapPoint;

                // Create attributes for the feature using the user selected health value.
                IEnumerable <KeyValuePair <string, object> > featureAttributes = new Dictionary <string, object>()
                {
                    { "Health", (short)healthValue }, { "Height", 3.2 }, { "Diameter", 1.2 }
                };

                // Ensure that the feature table is loaded.
                if (_featureTable.LoadStatus != Esri.ArcGISRuntime.LoadStatus.Loaded)
                {
                    await _featureTable.LoadAsync();
                }

                // Create the new feature
                ArcGISFeature newFeature = _featureTable.CreateFeature(featureAttributes, featurePoint) as ArcGISFeature;

                // Add the newly created feature to the feature table.
                await _featureTable.AddFeatureAsync(newFeature);

                // Apply the edits to the service feature table.
                await _featureTable.ApplyEditsAsync();

                // Reset the user interface.
                HelpLabel.Text = "Tap to create a feature";
                _graphicsOverlay.Graphics.Clear();
                AddButton.IsEnabled = false;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                await Application.Current.MainPage.DisplayAlert("Error", "Could not create feature", "OK");
            }
        }
Example #16
0
        public static async Task <object> GetAttribute(string url, string whereClause = "", string fieldName = "")
        {
            var table = new ServiceFeatureTable(new Uri(url));
            await table.LoadAsync();

            if (table.GeometryType != Esri.ArcGISRuntime.Geometry.GeometryType.Polygon)
            {
                return(null);
            }

            var queryParams = new QueryParameters();

            queryParams.WhereClause = whereClause;
            var count = await table.QueryFeatureCountAsync(queryParams);

            var queryFeatureResults = await table.QueryFeaturesAsync(queryParams);

            var resultingFeature = queryFeatureResults.FirstOrDefault();

            return(resultingFeature.GetAttributeValue(fieldName));
        }
Example #17
0
        private async void CreateFeatureTable()
        {
            var featureTableUri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0");

            serviceRequestTable = new ServiceFeatureTable(featureTableUri);

            var relatedTableUri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/1");

            relatedTable = new ServiceFeatureTable(relatedTableUri);

            // load the feature table
            await serviceRequestTable.LoadAsync();

            await relatedTable.LoadAsync();


            // if the table was loaded successfully, create a new feature layer for the table and add it to the map
            if (serviceRequestTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
            {
                serviceRequestLayer = new FeatureLayer(serviceRequestTable);
                MyMapView.Map.OperationalLayers.Add(serviceRequestLayer);
            }
        }
        private async void Initialize()
        {
            // Create a tile cache and load it with the SanFrancisco streets tpk.
            try
            {
                TileCache tileCache = new TileCache(DataManager.GetDataFolder("e4a398afe9a945f3b0f4dca1e4faccb5", "SanFrancisco.tpkx"));

                // Create the corresponding layer based on the tile cache.
                ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache);

                // Create the basemap based on the tile cache.
                Basemap sfBasemap = new Basemap(tileLayer);

                // Create the map with the tile-based basemap.
                Map myMap = new Map(sfBasemap);

                // Assign the map to the MapView.
                myMapView.Map = myMap;

                // Create a new symbol for the extent graphic.
                SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Red, 2);

                // Create a graphics overlay for the extent graphic and apply a renderer.
                GraphicsOverlay extentOverlay = new GraphicsOverlay
                {
                    Renderer = new SimpleRenderer(lineSymbol)
                };

                // Add the graphics overlay to the map view.
                myMapView.GraphicsOverlays.Add(extentOverlay);

                // Set up an event handler for when the viewpoint (extent) changes.
                myMapView.ViewpointChanged += MapViewExtentChanged;

                // Create a task for generating a geodatabase (GeodatabaseSyncTask).
                _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri);

                // Add all layers from the service to the map.
                foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos)
                {
                    // Get the URL for this layer.
                    Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id);

                    // Create the ServiceFeatureTable.
                    ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri);

                    // Wait for the table to load.
                    await onlineTable.LoadAsync();

                    // Skip tables that aren't for point features.{
                    if (onlineTable.GeometryType != GeometryType.Point)
                    {
                        continue;
                    }

                    // Add the layer to the map's operational layers if load succeeds.
                    if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
                    {
                        myMap.OperationalLayers.Add(new FeatureLayer(onlineTable));
                    }
                }

                // Update the graphic - needed in case the user decides not to interact before pressing the button.
                UpdateMapExtent();

                // Enable the generate button now that sample is ready.
                myGenerateButton.IsEnabled = true;
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK");
            }
        }
Example #19
0
        private async void Initialize()
        {
            try
            {
                // Create a tile cache and load it with the SanFrancisco streets tpk.
                TileCache tileCache = new TileCache(DataManager.GetDataFolder("3f1bbf0ec70b409a975f5c91f363fe7d", "SanFrancisco.tpk"));

                // Create the corresponding layer based on the tile cache.
                ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache);

                // Create the basemap based on the tile cache.
                Basemap sfBasemap = new Basemap(tileLayer);

                // Create the map with the tile-based basemap.
                Map map = new Map(sfBasemap);

                // Assign the map to the MapView.
                _myMapView.Map = map;

                // Create a new symbol for the extent graphic.
                SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2);

                // Create graphics overlay for the extent graphic and apply a renderer.
                GraphicsOverlay extentOverlay = new GraphicsOverlay
                {
                    Renderer = new SimpleRenderer(lineSymbol)
                };

                // Add graphics overlay to the map view.
                _myMapView.GraphicsOverlays.Add(extentOverlay);

                // Create a task for generating a geodatabase (GeodatabaseSyncTask).
                _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri);

                // Add all graphics from the service to the map.
                foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos)
                {
                    // Get the Uri for this particular layer.
                    Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id);

                    // Create the ServiceFeatureTable.
                    ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri);

                    // Wait for the table to load.
                    await onlineTable.LoadAsync();

                    // Skip tables that aren't for point features.{
                    if (onlineTable.GeometryType != GeometryType.Point)
                    {
                        continue;
                    }

                    // Add the layer to the map's operational layers if load succeeds.
                    if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
                    {
                        map.OperationalLayers.Add(new FeatureLayer(onlineTable));
                    }
                }

                // Update the graphic - needed in case the user decides not to interact before pressing the button.
                UpdateMapExtent();

                // Enable the generate button now that the sample is ready.
                _generateButton.Enabled = true;
            }
            catch (Exception ex)
            {
                ShowStatusMessage(ex.ToString());
            }
        }
Example #20
0
        private async void Initialize()
        {
            try
            {
                // Create a tile cache from a locally downloaded file.
                TileCache tileCache = new TileCache(DataManager.GetDataFolder("3f1bbf0ec70b409a975f5c91f363fe7d", "SanFrancisco.tpk"));

                // Create the corresponding layer based on the tile cache.
                ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache);

                // Create the basemap based on the tile cache.
                Basemap sfBasemap = new Basemap(tileLayer);

                // Create the map with the tile-based basemap.
                Map myMap = new Map(sfBasemap);

                // Assign the map to the MapView.
                MyMapView.Map = myMap;

                // Create a new symbol for the extent graphic.
                SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2);

                // Create graphics overlay for the extent graphic and apply a renderer.
                GraphicsOverlay extentOverlay = new GraphicsOverlay
                {
                    Renderer = new SimpleRenderer(lineSymbol)
                };

                // Add graphics overlay to the map view.
                MyMapView.GraphicsOverlays.Add(extentOverlay);

                // Set up an event handler for when the viewpoint (extent) changes.
                MyMapView.ViewpointChanged += UpdateMapExtent;

                // Create a task for generating a geodatabase (GeodatabaseSyncTask).
                _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri);

                // Add all graphics from the service to the map.
                foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos)
                {
                    // Create the ServiceFeatureTable for this layer.
                    ServiceFeatureTable onlineTable = new ServiceFeatureTable(new Uri(_featureServiceUri + "/" + layer.Id));

                    // Wait for the table to load.
                    await onlineTable.LoadAsync();

                    // Add the layer to the map's operational layers if load succeeds.
                    if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
                    {
                        myMap.OperationalLayers.Add(new FeatureLayer(onlineTable));
                    }
                }

                // Update the graphic - needed in case the user decides not to interact before pressing the button.
                UpdateMapExtent(null, null);

                // Enable the generate button.
                MyGenerateButton.IsEnabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }