コード例 #1
0
        private async void Initialize()
        {
            // Initialize the map with an oceans basemap.
            _myMapView.Map = new Map(Basemap.CreateOceans());

            // Get the path to the ENC Exchange Set.
            string encPath = DataManager.GetDataFolder("9d2987a825c646468b3ce7512fb76e2d", "ExchangeSetwithoutUpdates", "ENC_ROOT", "CATALOG.031");

            // Create the Exchange Set.
            // Note: this constructor takes an array of paths because so that update sets can be loaded alongside base data.
            EncExchangeSet encExchangeSet = new EncExchangeSet(encPath);

            try
            {
                // Wait for the layer to load.
                await encExchangeSet.LoadAsync();

                // Store a list of data set extent's - will be used to zoom the mapview to the full extent of the Exchange Set.
                List <Envelope> dataSetExtents = new List <Envelope>();

                // Add each data set as a layer.
                foreach (EncDataset encDataSet in encExchangeSet.Datasets)
                {
                    EncLayer encLayer = new EncLayer(new EncCell(encDataSet));

                    // Add the layer to the map.
                    _myMapView.Map.OperationalLayers.Add(encLayer);

                    // Wait for the layer to load.
                    await encLayer.LoadAsync();

                    // Add the extent to the list of extents.
                    dataSetExtents.Add(encLayer.FullExtent);
                }

                // Use the geometry engine to compute the full extent of the ENC Exchange Set.
                Envelope fullExtent = GeometryEngine.CombineExtents(dataSetExtents);

                // Set the viewpoint.
                await _myMapView.SetViewpointAsync(new Viewpoint(fullExtent));
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
コード例 #2
0
        private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // First clear any existing selections.
            ClearAllSelections();

            try
            {
                // Perform the identify operation.
                IReadOnlyList <IdentifyLayerResult> results = await _myMapView.IdentifyLayersAsync(e.Position, 5, false);

                // Return if there are no results.
                if (results.Count < 1)
                {
                    return;
                }

                // Get the results that are from ENC layers.
                IEnumerable <IdentifyLayerResult> encResults = results.Where(result => result.LayerContent is EncLayer);

                // Get the ENC results that have features.
                IEnumerable <IdentifyLayerResult> encResultsWithFeatures = encResults.Where(result => result.GeoElements.Count > 0);

                // Get the first result with ENC features.
                IdentifyLayerResult firstResult = encResultsWithFeatures.First();

                // Get the layer associated with this set of results.
                EncLayer containingLayer = (EncLayer)firstResult.LayerContent;

                // Get the first identified ENC feature.
                EncFeature smallestFeature = (EncFeature)firstResult.GeoElements.OrderBy(f => GeometryEngine.Area(f.Geometry)).First();

                // Select the feature.
                containingLayer.SelectFeature(smallestFeature);

                // Create the callout definition.
                CalloutDefinition definition = new CalloutDefinition(smallestFeature.Acronym, smallestFeature.Description);

                // Show the callout.
                _myMapView.ShowCalloutAt(e.Location, definition);
            }
            catch (Exception ex)
            {
                new UIAlertView("Error", ex.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
コード例 #3
0
        private async void Initialize()
        {
            // Subscribe to event notifications
            _colorSchemeSegment.ValueChanged += ColorSchemeChanged;
            _areaSegment.ValueChanged        += AreaStyleChanged;
            _pointSegment.ValueChanged       += PointStyleChanged;

            // Initialize the map with an oceans basemap
            _myMapView.Map = new Map(Basemap.CreateOceans());

            // Get the path to the ENC Exchange Set
            string encPath = DataManager.GetDataFolder("9d2987a825c646468b3ce7512fb76e2d", "ExchangeSetwithoutUpdates", "ENC_ROOT",
                                                       "CATALOG.031");

            // Create the Exchange Set
            // Note: this constructor takes an array of paths because so that update sets can be loaded alongside base data
            EncExchangeSet myEncExchangeSet = new EncExchangeSet(encPath);

            // Wait for the layer to load
            await myEncExchangeSet.LoadAsync();

            // Store a list of data set extent's - will be used to zoom the mapview to the full extent of the Exchange Set
            List <Envelope> dataSetExtents = new List <Envelope>();

            // Add each data set as a layer
            foreach (EncDataset myEncDataSet in myEncExchangeSet.Datasets)
            {
                EncLayer myEncLayer = new EncLayer(new EncCell(myEncDataSet));

                // Add the layer to the map
                _myMapView.Map.OperationalLayers.Add(myEncLayer);

                // Wait for the layer to load
                await myEncLayer.LoadAsync();

                // Add the extent to the list of extents
                dataSetExtents.Add(myEncLayer.FullExtent);
            }

            // Use the geometry engine to compute the full extent of the ENC Exchange Set
            Envelope fullExtent = GeometryEngine.CombineExtents(dataSetExtents);

            // Set the viewpoint
            _myMapView.SetViewpoint(new Viewpoint(fullExtent));
        }
コード例 #4
0
        private async void Initialize()
        {
            // Initialize the map with an oceans basemap.
            MyMapView.Map = new Map(Basemap.CreateOceans());

            // Get the path to the ENC Exchange Set.
            string encPath = DataManager.GetDataFolder("9d2987a825c646468b3ce7512fb76e2d", "ExchangeSetwithoutUpdates", "ENC_ROOT", "CATALOG.031");

            // Create the Exchange Set.
            // Note: this constructor takes an array of paths because so that update sets can be loaded alongside base data.
            EncExchangeSet myEncExchangeSet = new EncExchangeSet(encPath);

            // Wait for the exchange set to load.
            await myEncExchangeSet.LoadAsync();

            // Store a list of data set extent's - will be used to zoom the mapview to the full extent of the Exchange Set.
            List <Envelope> dataSetExtents = new List <Envelope>();

            // Add each data set as a layer.
            foreach (EncDataset myEncDataset in myEncExchangeSet.Datasets)
            {
                // Create the cell and layer.
                EncLayer myEncLayer = new EncLayer(new EncCell(myEncDataset));

                // Add the layer to the map.
                MyMapView.Map.OperationalLayers.Add(myEncLayer);

                // Wait for the layer to load.
                await myEncLayer.LoadAsync();

                // Add the extent to the list of extents.
                dataSetExtents.Add(myEncLayer.FullExtent);
            }

            // Use the geometry engine to compute the full extent of the ENC Exchange Set.
            Envelope fullExtent = GeometryEngine.CombineExtents(dataSetExtents);

            // Set the viewpoint.
            MyMapView.SetViewpoint(new Viewpoint(fullExtent));

            // Subscribe to tap events (in order to use them to identify and select features).
            MyMapView.GeoViewTapped += MyMapView_GeoViewTapped;
        }
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            // First clear any existing selections
            ClearAllSelections();

            try
            {
                // Perform the identify operation.
                IReadOnlyList <IdentifyLayerResult> results = await MyMapView.IdentifyLayersAsync(e.Position, 10, false);

                // Return if there are no results.
                if (results.Count < 1)
                {
                    return;
                }

                // Get the results that are from ENC layers.
                IEnumerable <IdentifyLayerResult> encResults = results.Where(result => result.LayerContent is EncLayer);

                // Get the first result with ENC features. (Depending on the data, there may be more than one IdentifyLayerResult that contains ENC features.)
                IdentifyLayerResult firstResult = encResults.First();

                // Get the layer associated with this set of results.
                EncLayer containingLayer = (EncLayer)firstResult.LayerContent;

                // Get the GeoElement identified in this layer.
                EncFeature encFeature = (EncFeature)firstResult.GeoElements.First();

                // Select the feature.
                containingLayer.SelectFeature(encFeature);

                // Create the callout definition.
                CalloutDefinition definition = new CalloutDefinition(encFeature.Acronym, encFeature.Description);

                // Show the callout.
                MyMapView.ShowCalloutAt(e.Location, definition);
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK");
            }
        }
コード例 #6
0
        private async void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            // First clear any existing selections
            ClearAllSelections();

            // Perform the identify operation
            IReadOnlyList <IdentifyLayerResult> results = await MyMapView.IdentifyLayersAsync(e.Position, 5, false);

            // Return if there are no results
            if (results.Count < 1)
            {
                return;
            }

            // Get the results that are from ENC layers
            IEnumerable <IdentifyLayerResult> encResults = results.Where(result => result.LayerContent is EncLayer);

            // Get the ENC results that have features
            IEnumerable <IdentifyLayerResult> encResultsWithFeatures = encResults.Where(result => result.GeoElements.Count > 0);

            // Get the first result with ENC features
            IdentifyLayerResult firstResult = encResultsWithFeatures.First();

            // Get the layer associated with this set of results
            EncLayer containingLayer = firstResult.LayerContent as EncLayer;

            // Select the smallest (area) feature in the layer.
            EncFeature smallestFeature = (EncFeature)firstResult.GeoElements.OrderBy(f => GeometryEngine.Area(f.Geometry)).First();

            // Select the feature.
            containingLayer.SelectFeature(smallestFeature);

            // Create the callout definition.
            CalloutDefinition definition = new CalloutDefinition(smallestFeature.Acronym, smallestFeature.Description);

            // Show the callout
            MyMapView.ShowCalloutAt(e.Location, definition);
        }
コード例 #7
0
        private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // First clear any existing selections
            ClearAllSelections();

            // Perform the identify operation
            IReadOnlyList <IdentifyLayerResult> results = await _myMapView.IdentifyLayersAsync(e.Position, 5, false);

            // Return if there are no results
            if (results.Count < 1)
            {
                return;
            }

            // Get the results that are from ENC layers
            IEnumerable <IdentifyLayerResult> encResults = results.Where(result => result.LayerContent is EncLayer);

            // Get the ENC results that have features
            IEnumerable <IdentifyLayerResult> encResultsWithFeatures = encResults.Where(result => result.GeoElements.Count > 0);

            // Get the first result with ENC features
            IdentifyLayerResult firstResult = encResultsWithFeatures.First();

            // Get the layer associated with this set of results
            EncLayer containingLayer = firstResult.LayerContent as EncLayer;

            // Get the first identified ENC feature
            EncFeature firstFeature = firstResult.GeoElements.First() as EncFeature;

            // Select the feature
            containingLayer.SelectFeature(firstFeature);

            // Create the callout definition
            CalloutDefinition definition = new CalloutDefinition(firstFeature.Acronym, firstFeature.Description);

            // Show the callout
            _myMapView.ShowCalloutAt(e.Location, definition);
        }
コード例 #8
0
        private async void Initialize()
        {
            // Initialize the map with an oceans basemap
            _myMapView.Map = new Map(Basemap.CreateOceans());

            // Get the path to the ENC Exchange Set
            string encPath = GetEncPath();

            // Create the cell and layer
            EncLayer encLayer = new EncLayer(new EncCell(encPath));

            // Add the layer to the map
            _myMapView.Map.OperationalLayers.Add(encLayer);

            // Wait for the layer to load
            await encLayer.LoadAsync();

            // Set the viewpoint
            await _myMapView.SetViewpointAsync(new Viewpoint(encLayer.FullExtent));

            // Subscribe to tap events (in order to use them to identify and select features)
            _myMapView.GeoViewTapped += MyMapView_GeoViewTapped;
        }
コード例 #9
0
        private async void Initialize()
        {
            // Initialize the map with an oceans basemap.
            _myMapView.Map = new Map(Basemap.CreateOceans());

            // Get the path to the ENC Exchange Set.
            string encPath = DataManager.GetDataFolder("a490098c60f64d3bbac10ad131cc62c7", "GB5X01NW.000");

            // Create the cell and layer.
            EncLayer encLayer = new EncLayer(new EncCell(encPath));

            // Add the layer to the map.
            _myMapView.Map.OperationalLayers.Add(encLayer);

            // Wait for the layer to load.
            await encLayer.LoadAsync();

            // Set the viewpoint.
            _myMapView.SetViewpoint(new Viewpoint(encLayer.FullExtent));

            // Subscribe to tap events (in order to use them to identify and select features).
            _myMapView.GeoViewTapped += MyMapView_GeoViewTapped;
        }
        private async void Initialize()
        {
            // Apply initial display settings
            UpdateDisplaySettings();

            // Initialize the map with an oceans basemap
            MyMapView.Map = new Map(Basemap.CreateOceans());

            // Get the path to the ENC Exchange Set
            string encPath = DataManager.GetDataFolder("9d2987a825c646468b3ce7512fb76e2d", "ExchangeSetwithoutUpdates", "ENC_ROOT",
                                                       "CATALOG.031");

            // Create the Exchange Set
            // Note: this constructor takes an array of paths because so that update sets can be loaded alongside base data
            EncExchangeSet myEncExchangeSet = new EncExchangeSet(encPath);

            try
            {
                // Wait for the exchange set to load
                await myEncExchangeSet.LoadAsync();

                // Store a list of data set extent's - will be used to zoom the mapview to the full extent of the Exchange Set
                List <Envelope> dataSetExtents = new List <Envelope>();

                // Add each data set as a layer
                foreach (EncDataset myEncDataSet in myEncExchangeSet.Datasets)
                {
                    // Create the cell and layer
                    EncLayer myEncLayer = new EncLayer(new EncCell(myEncDataSet));

                    // Add the layer to the map
                    MyMapView.Map.OperationalLayers.Add(myEncLayer);

                    // Wait for the layer to load
                    await myEncLayer.LoadAsync();

                    // Add the extent to the list of extents
                    dataSetExtents.Add(myEncLayer.FullExtent);
                }

                // Use the geometry engine to compute the full extent of the ENC Exchange Set
                Envelope fullExtent = GeometryEngine.CombineExtents(dataSetExtents);

                // Set the viewpoint
                MyMapView.SetViewpoint(new Viewpoint(fullExtent));

                // Subscribe to notifications about leaving so that settings can be re-set
                this.Unloaded += Sample_Unloaded;

                // Enable changing the settings on user interaction
                DayRadioButton.Checked            += Setting_Checked;
                NightRadioButton.Checked          += Setting_Checked;
                DuskRadioButton.Checked           += Setting_Checked;
                PlainAreaRadioButton.Checked      += Setting_Checked;
                SymbolizedAreaRadioButton.Checked += Setting_Checked;
                PaperchartRadioButton.Checked     += Setting_Checked;
                SimplifiedRadioButton.Checked     += Setting_Checked;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
            }
        }
        private async void Initialize()
        {
            // Add display options to UI
            ColorSchemePicker.ItemsSource = new List <String>()
            {
                "Day", "Dusk", "Night"
            };
            AreaPicker.ItemsSource = new List <String>()
            {
                "Plain", "Symbolized"
            };
            PointPicker.ItemsSource = new List <String>()
            {
                "Paper Chart", "Simplified"
            };

            // Provide initial selection
            ColorSchemePicker.SelectedIndex = 0; AreaPicker.SelectedIndex = 0; PointPicker.SelectedIndex = 0;

            // Apply initial display settings
            UpdateDisplaySettings();

            // Initialize the map with an oceans basemap
            MyMapView.Map = new Map(BasemapStyle.ArcGISOceans);

            // Get the path to the ENC Exchange Set
            string encPath = DataManager.GetDataFolder("9d2987a825c646468b3ce7512fb76e2d", "ExchangeSetwithoutUpdates", "ENC_ROOT",
                                                       "CATALOG.031");

            // Create the Exchange Set
            // Note: this constructor takes an array of paths because so that update sets can be loaded alongside base data
            EncExchangeSet myEncExchangeSet = new EncExchangeSet(new string[] { encPath });

            try
            {
                // Wait for the exchange set to load
                await myEncExchangeSet.LoadAsync();

                // Store a list of data set extent's - will be used to zoom the mapview to the full extent of the Exchange Set
                List <Envelope> dataSetExtents = new List <Envelope>();

                // Add each data set as a layer
                foreach (EncDataset myEncDataSet in myEncExchangeSet.Datasets)
                {
                    EncLayer myEncLayer = new EncLayer(new EncCell(myEncDataSet));

                    // Add the layer to the map
                    MyMapView.Map.OperationalLayers.Add(myEncLayer);

                    // Wait for the layer to load
                    await myEncLayer.LoadAsync();

                    // Add the extent to the list of extents
                    dataSetExtents.Add(myEncLayer.FullExtent);
                }

                // Use the geometry engine to compute the full extent of the ENC Exchange Set
                Envelope fullExtent = GeometryEngine.CombineExtents(dataSetExtents);

                // Set the viewpoint
                await MyMapView.SetViewpointAsync(new Viewpoint(fullExtent));

                // Subscribe to notifications about leaving so that settings can be reset.
                // This looks different because of sample viewer plumbing.
                // Replace `((ArcGISRuntime.SamplePage)this.Parent)` with `this` in your app.
                ((Page)this.Parent).Disappearing += SampleUnloaded;
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }