Exemple #1
0
        private async void Initialize()
        {
            Map myMap = new Map();

            Envelope initialLocation = new Envelope(
                136.6, 35.72, 139.65, 35.68, SpatialReferences.Wgs84);

            myMap.InitialViewpoint = new Viewpoint(initialLocation);

            // create a WMTS service from a URL
            //var WmtsUrl = new System.Uri("https://esrijapan.github.io/gsi-wmts/chizu_shashin.xml");
            var WmtsUrl = new System.Uri("https://gbank.gsj.jp/seamless/tilemap/basic/WMTSCapabilities.xml");

            WmtsService wmtsService = new WmtsService(WmtsUrl);

            await wmtsService.LoadAsync();

            if (wmtsService.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
            {
                WmtsServiceInfo wmtsServiceInfo          = wmtsService.ServiceInfo;
                IReadOnlyList <WmtsLayerInfo> layerInfos = wmtsServiceInfo.LayerInfos;

                WmtsLayer wmtsLayer = new WmtsLayer(layerInfos[0]);
                //WmtsLayer wmtsLayer = new WmtsLayer();

                myMap.Basemap = new Basemap(wmtsLayer);
            }
            else
            {
                // todo
            }

            MyMapView.Map = myMap;
        }
Exemple #2
0
        private async Task LoadWMTSLayerAsync(bool uriMode)
        {
            try
            {
                // Create a new map.
                Map myMap = new Map();

                // Get the basemap from the map.
                Basemap myBasemap = myMap.Basemap;

                // Get the layer collection for the base layers.
                LayerCollection myLayerCollection = myBasemap.BaseLayers;

                // Create an instance for the WMTS layer.
                WmtsLayer myWmtsLayer;

                // Define the Uri to the WMTS service.
                Uri wmtsUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS");

                if (uriMode)
                {
                    // Create a WMTS layer using a Uri and provide an Id value.
                    myWmtsLayer = new WmtsLayer(wmtsUri, "WorldTimeZones");
                }
                else
                {
                    // Define a new instance of the WMTS service.
                    WmtsService myWmtsService = new WmtsService(wmtsUri);

                    // Load the WMTS service.
                    await myWmtsService.LoadAsync();

                    // Get the service information (i.e. metadata) about the WMTS service.
                    WmtsServiceInfo myWmtsServiceInfo = myWmtsService.ServiceInfo;

                    // Obtain the read only list of WMTS layer info objects.
                    IReadOnlyList <WmtsLayerInfo> myWmtsLayerInfos = myWmtsServiceInfo.LayerInfos;

                    // Create a WMTS layer using the first item in the read only list of WMTS layer info objects.
                    myWmtsLayer = new WmtsLayer(myWmtsLayerInfos[0]);
                }

                // Add the WMTS layer to the layer collection of the map.
                myLayerCollection.Add(myWmtsLayer);

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

                // Zoom to appropriate level for iOS.
                await _myMapView.SetViewpointScaleAsync(300000000);
            }
            catch (Exception ex)
            {
                UIAlertController alert = UIAlertController.Create("Error", ex.Message, UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alert, true, null);
            }
        }
Exemple #3
0
        private async void LoadWMTSLayer(bool uriMode)
        {
            try
            {
                // Create a new map.
                Map myMap = new Map();

                // Get the basemap from the map.
                Basemap myBasemap = myMap.Basemap;

                // Get the layer collection for the base layers.
                LayerCollection myLayerCollection = myBasemap.BaseLayers;

                // Create an instance for the WMTS layer.
                WmtsLayer myWmtsLayer;

                // Define the Uri to the WMTS service.
                Uri wmtsUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS");

                if (uriMode)
                {
                    // Create a WMTS layer using a Uri and provide an Id value.
                    myWmtsLayer = new WmtsLayer(wmtsUri, "WorldTimeZones");
                }
                else
                {
                    // Define a new instance of the WMTS service.
                    WmtsService myWmtsService = new WmtsService(wmtsUri);

                    // Load the WMTS service.
                    await myWmtsService.LoadAsync();

                    // Get the service information (i.e. metadata) about the WMTS service.
                    WmtsServiceInfo myWmtsServiceInfo = myWmtsService.ServiceInfo;

                    // Obtain the read only list of WMTS layer info objects.
                    IReadOnlyList <WmtsLayerInfo> myWmtsLayerInfos = myWmtsServiceInfo.LayerInfos;

                    // Create a WMTS layer using the first item in the read only list of WMTS layer info objects.
                    myWmtsLayer = new WmtsLayer(myWmtsLayerInfos[0]);
                }

                // Add the WMTS layer to the layer collection of the map.
                myLayerCollection.Add(myWmtsLayer);

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

                // Zoom to appropriate level for iOS.
                await MyMapView.SetViewpointScaleAsync(300000000);
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Sample error", ex.ToString(), "OK");
            }
        }
        private async void LoadWMTSLayer(bool uriMode)
        {
            try
            {
                // Create a new map.
                Map myMap = new Map();

                // Get the basemap from the map.
                Basemap myBasemap = myMap.Basemap;

                // Get the layer collection for the base layers.
                LayerCollection myLayerCollection = myBasemap.BaseLayers;

                // Create an instance for the WMTS layer.
                WmtsLayer myWmtsLayer;

                // Define the Uri to the WMTS service.
                Uri wmtsUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS");

                if (uriMode)
                {
                    // Create a WMTS layer using a Uri and provide an Id value.
                    myWmtsLayer = new WmtsLayer(wmtsUri, "WorldTimeZones");
                }
                else
                {
                    // Define a new instance of the WMTS service.
                    WmtsService myWmtsService = new WmtsService(wmtsUri);

                    // Load the WMTS service.
                    await myWmtsService.LoadAsync();

                    // Get the service information (i.e. metadata) about the WMTS service.
                    WmtsServiceInfo myWmtsServiceInfo = myWmtsService.ServiceInfo;

                    // Obtain the read only list of WMTS layer info objects.
                    IReadOnlyList <WmtsLayerInfo> myWmtsLayerInfos = myWmtsServiceInfo.LayerInfos;

                    // Create a WMTS layer using the first item in the read only list of WMTS layer info objects.
                    myWmtsLayer = new WmtsLayer(myWmtsLayerInfos[0]);
                }

                // Add the WMTS layer to the layer collection of the map.
                myLayerCollection.Add(myWmtsLayer);

                // Assign the map to the MapView.
                _myMapView.Map = myMap;
            }
            catch (Exception ex)
            {
                AlertDialog alert = new AlertDialog.Builder(this).Create();
                alert.SetMessage(ex.Message);
                alert.Show();
            }
        }
        private async void Button2_Clicked(object sender, EventArgs e)
        {
            // Create dialog to display alert information
            var alert = new AlertDialog.Builder(this);

            try
            {
                // Define the Uri to the WMTS service
                var myUri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS");

                // Define a new instance of the WMTS service
                WmtsService myWmtsService = new WmtsService(myUri);

                // Load the WMTS service
                await myWmtsService.LoadAsync();

                // Get the service information (i.e. metadata) about the WMTS service
                WmtsServiceInfo myWMTSServiceInfo = myWmtsService.ServiceInfo;

                // Obtain the read only list of WMTS layer info objects
                IReadOnlyList <WmtsLayerInfo> myWmtsLayerInfos = myWMTSServiceInfo.LayerInfos;

                // Create a new instance of a WMTS layer using the first item in the read only list of WMTS layer info objects
                WmtsLayer myWmtsLayer = new WmtsLayer(myWmtsLayerInfos[0]);

                // Create a new map
                Map myMap = new Map();

                // Get the basemap from the map
                Basemap myBasemap = myMap.Basemap;

                // Get the layer collection for the base layers
                LayerCollection myLayerCollection = myBasemap.BaseLayers;

                // Add the WMTS layer to the layer collection of the map
                myLayerCollection.Add(myWmtsLayer);

                // Assign the map to the MapView
                _myMapView.Map = myMap;
            }
            catch (Exception ex)
            {
                alert.SetTitle("Sample Error");
                alert.SetMessage(ex.Message);
                alert.Show();
            }
        }
        private async void OnButton2Clicked(object sender, EventArgs e)
        {
            try
            {
                // Define the Uri to the WMTS service (NOTE: iOS applications require the use of Uri's to be https:// and not http://)
                var myUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS");

                // Define a new instance of the WMTS service
                WmtsService myWmtsService = new WmtsService(myUri);

                // Load the WMTS service
                await myWmtsService.LoadAsync();

                // Get the service information (i.e. metadata) about the WMTS service
                WmtsServiceInfo myWMTSServiceInfo = myWmtsService.ServiceInfo;

                // Obtain the read only list of WMTS layer info objects
                IReadOnlyList <WmtsLayerInfo> myWmtsLayerInfos = myWMTSServiceInfo.LayerInfos;

                // Create a new instance of a WMTS layer using the first item in the read only list of WMTS layer info objects
                WmtsLayer myWmtsLayer = new WmtsLayer(myWmtsLayerInfos[0]);

                // Create a new map
                Map myMap = new Map();

                // Get the basemap from the map
                Basemap myBasemap = myMap.Basemap;

                // Get the layer collection for the base layers
                LayerCollection myLayerCollection = myBasemap.BaseLayers;

                // Add the WMTS layer to the layer collection of the map
                myLayerCollection.Add(myWmtsLayer);

                // Assign the map to the MapView
                _myMapView.Map = myMap;
            }
            catch (Exception ex)
            {
                // Report error
                UIAlertController alert = UIAlertController.Create("Error", ex.Message, UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alert, true, null);
            }
        }
        private async void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                // Define the Uri to the WMTS service (NOTE: iOS applications require the use of Uri's to be https:// and not http://)
                var myUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS");

                // Define a new instance of the WMTS service
                WmtsService myWmtsService = new WmtsService(myUri);

                // Load the WMTS service
                await myWmtsService.LoadAsync();

                // Get the service information (i.e. metadata) about the WMTS service
                WmtsServiceInfo myWMTSServiceInfo = myWmtsService.ServiceInfo;

                // Obtain the read only list of WMTS layer info objects
                IReadOnlyList <WmtsLayerInfo> myWmtsLayerInfos = myWMTSServiceInfo.LayerInfos;

                // Create a new instance of a WMTS layer using the first item in the read only list of WMTS layer info objects
                WmtsLayer myWmtsLayer = new WmtsLayer(myWmtsLayerInfos[0]);

                // Create a new map
                Map myMap = new Map();

                // Get the basemap from the map
                Basemap myBasemap = myMap.Basemap;

                // Get the layer collection for the base layers
                LayerCollection myLayerCollection = myBasemap.BaseLayers;

                // Add the WMTS layer to the layer collection of the map
                myLayerCollection.Add(myWmtsLayer);

                // Assign the map to the MapView
                MyMapView.Map = myMap;
            }
            catch (Exception ex)
            {
                await DisplayAlert("Sample error", ex.ToString(), "OK");
            }
        }
Exemple #8
0
        public async Task <Basemap> GetTopoBasemapAsync()
        {
            var wmtsUri = new Uri(ServiceConfig.SwedishTopographic);

            WmtsService myWmtsService = new WmtsService(wmtsUri);

            // Load the WMTS service.
            await myWmtsService.LoadAsync();

            // Get the service information (i.e. metadata) about the WMTS service.
            WmtsServiceInfo myWmtsServiceInfo = myWmtsService.ServiceInfo;

            // Obtain the read only list of WMTS layer info objects.
            IReadOnlyList <WmtsLayerInfo> myWmtsLayerInfos = myWmtsServiceInfo.LayerInfos;

            // Create a WMTS layer using the first item in the read only list of WMTS layer info objects.
            var myWmtsLayer = new WmtsLayer(myWmtsLayerInfos.LastOrDefault());

            return(new Basemap(myWmtsLayer));
        }
        }   // end SelectedDateChanged


        // Initialize WMTS data
        private async void InitializeWMTS()
        {
            String str;
            WmtsService wmtsService;
            Uri wmtsServiceURI;

            // Create the WMTS Service Load data from the URI
            WMTS_CAP_URL = "https://gibs.earthdata.nasa.gov/wmts/" + wmsUriStartup.EPSG
                            + "/" + wmsUriStartup.latency + "/1.0.0/WMTSCapabilities.xml";
            wmtsServiceURI = new Uri(WMTS_CAP_URL);

            // Define an instance of the service
            wmtsService = new WmtsService(wmtsServiceURI);

            // If service can load, initialize the app
            try
            {
                if (aoiWin == null)
                    aoiWin = new AOIWindow();

                // Load the WMS Service.
                await wmtsService.LoadAsync();

                // Get the service info (metadata) from the service.
                wmts.serviceInfo = wmtsService.ServiceInfo;

                // Get the WMTS tile information
                wmts.tileSets = new List<WMTS.TileSetVariables>();
                for (int i = 0; i < selectedLayers.Count; i++)
                {
                    wmts.tileSets.Add(new WMTS.TileSetVariables());
                    wmts.tileSets[i].tileSetTitle = wmts.serviceInfo.TileMatrixSets[i].Id;
                    wmts.tileSets[i].zoomLvls = wmts.serviceInfo.TileMatrixSets[i].TileMatrices.Count;
                    for (int j = 0; j < wmts.serviceInfo.TileMatrixSets[i].TileMatrices.Count; j++)
                    {
                        wmts.tileSets[i].resTypes.Add(new WMTS.ResType());
                        wmts.tileSets[i].resTypes[j].id =
                            wmts.serviceInfo.TileMatrixSets[i].TileMatrices[j].Id;
                        wmts.tileSets[i].resTypes[j].scaleDenom =
                            wmts.serviceInfo.TileMatrixSets[i].TileMatrices[j].ScaleDenominator;
                    }
                }

                // Obtain the read only list of WMTS layers info objects
                // for selected layers
                wmts.selectedLayers = new List<WmtsLayerInfo>();
                foreach (WmsLayerInfo wmsLayerInfo in selectedLayers)
                {
                    str = wmsLayerInfo.Title;
                    foreach (WmtsLayerInfo wmtsLayerInfo in wmts.serviceInfo.LayerInfos)
                    {
                        // Got a layer - save info about this layer
                        if (str == wmtsLayerInfo.Title)
                        {
                            wmts.selectedLayers.Add(wmtsLayerInfo);
                            break;
                        }
                    }
                }

                // Set up tile matrix information for selected tiles
                wmts.layerTileSets = new List<WMTS.TileSetVariables>();
                for (int i = 0; i < wmts.selectedLayers.Count; i++)
                {
                    wmts.layerTileSets.Add(new WMTS.TileSetVariables());
                    wmts.layerTileSets[i].zoomLvls = wmts.selectedLayers[i].TileMatrixSets[0].TileMatrices.Count;
                    wmts.layerTileSets[i].tileSetTitle =
                         wmts.selectedLayers[i].TileMatrixSets[0].Id;
                    wmts.layerTileSets[i].layerTitle = wmts.selectedLayers[i].Title;
                    wmts.layerTileSets[i].layerName = wmts.selectedLayers[i].Id;
                    wmts.layerTileSets[i].tileWidth = TILE_WIDTH;
                    wmts.layerTileSets[i].tileHeight = TILE_HEIGHT;

                    // get tile matrices info
                    for (int j = 0; j < wmts.selectedLayers[i].TileMatrixSets[0].TileMatrices.Count; j++)
                    {
                        wmts.layerTileSets[i].resTypes.Add(new WMTS.ResType());
                        wmts.layerTileSets[i].resTypes[j].id =
                            wmts.selectedLayers[i].TileMatrixSets[0].TileMatrices[j].Id;
                        wmts.layerTileSets[i].resTypes[j].scaleDenom =
                            wmts.selectedLayers[i].TileMatrixSets[0].TileMatrices[j].ScaleDenominator;
                        wmts.layerTileSets[i].resTypes[j].resolution =
                            wmts.layerTileSets[i].resTypes[j].scaleDenom / 397569610;
                        wmts.layerTileSets[i].resTypes[j].matrixWidth = 2 ^ j;
                        wmts.layerTileSets[i].resTypes[j].matrixHeight = 2 ^ j;
                    }
                }

                // Set AOI window Titles
                aoiWin.panelVars.titleList = new List<string>();
                foreach (WMTS.TileSetVariables tileSet in wmts.layerTileSets)
                {
                    str = tileSet.layerTitle + "\n" +
                          "Tile Set: " + tileSet.tileSetTitle + "\t"
                          + "Zoom Levels: " + tileSet.zoomLvls;
                    aoiWin.panelVars.titleList.Add(str);
                }

                aoiWin.ImageryTitle.ItemsSource = aoiWin.panelVars.titleList;
                aoiWin.ImageryTitle.SelectedIndex = 0;

                // Set the zoom level specific to image selected
                ResetZoomLevels(aoiWin.ImageryTitle.SelectedIndex, "Skipper");
            }   // end try

            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "WMTS SERVER LOAD ERROR");
            }
        }   // end InitializeWMTS