Beispiel #1
0
        private async void Initialize()
        {
            // Create a new Map instance with the basemap.
            Map map = new Map(SpatialReferences.Wgs84)
            {
                Basemap = Basemap.CreateTopographic()
            };

            // Create a new ArcGISMapImageLayer instance and pass a URL to the service.
            _mapImageLayer = new ArcGISMapImageLayer(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer"));

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

            // Create a new instance of the Sublayers Table View Controller. This View Controller
            // displays a table of sublayers with a switch for setting the layer visibility.
            _sublayersTableView = new SublayersTable();

            try
            {
                // Await the load call for the layer.
                await _mapImageLayer.LoadAsync();

                // Add the map image layer to the map's operational layers.
                map.OperationalLayers.Add(_mapImageLayer);
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
Beispiel #2
0
        private async void Initialize()
        {
            // Create a new ArcGISMapImageLayer instance and pass a URL to the service.
            var mapImageLayer = new ArcGISMapImageLayer(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer"));

            // Await the load call for the layer..
            await mapImageLayer.LoadAsync();

            // Create a new Map instance with the basemap..
            Map map = new Map(SpatialReferences.Wgs84)
            {
                Basemap = Basemap.CreateTopographic()
            };

            // Add the map image layer to the map's operational layers.
            map.OperationalLayers.Add(mapImageLayer);

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

            // Create a new instance of the Sublayers Table View Controller. This View Controller
            // displays a table of sublayers with a switch for setting the layer visibility.
            SublayersTable sublayersTableView = new SublayersTable();

            // When the sublayers button is clicked, load the Sublayer Table View Controller.
            _sublayersButton.TouchUpInside += (s, e) =>
            {
                if (mapImageLayer.Sublayers.Count > 0)
                {
                    sublayersTableView.MapImageLayer = mapImageLayer;
                    NavigationController.PushViewController(sublayersTableView, true);
                }
            };
        }
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Create a new ArcGISMapImageLayer instance and pass a Url to the service
            var mapImageLayer = new ArcGISMapImageLayer(
                new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer"));

            // Await the load call for the layer.
            await mapImageLayer.LoadAsync();

            // Create a new Map instance with the basemap
            Map myMap = new Map(SpatialReferences.Wgs84);

            myMap.Basemap = Basemap.CreateTopographic();

            // Add the map image layer to the map's operational layers
            myMap.OperationalLayers.Add(mapImageLayer);

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

            sublayersButton.BackgroundColor = UIColor.White;
            sublayersButton.SetTitle("Sublayers", UIControlState.Normal);
            sublayersButton.SetTitleColor(UIColor.Blue, UIControlState.Normal);

            // Create a new instance of the Sublayers Table View Controller. This View Controller
            // displays a table of sublayers with a switch for setting the layer visibility.
            SublayersTable sublayersTableView = new SublayersTable();

            // When the sublayers button is clicked, load the Sublayers Table View Controller
            sublayersButton.TouchUpInside += (s, e) =>
            {
                if (mapImageLayer.Sublayers.Count > 0)
                {
                    sublayersTableView.mapImageLayer = mapImageLayer;
                    NavigationController.PushViewController(sublayersTableView, true);
                }
            };

            // Add the MapView and Sublayers button to the View
            View.AddSubviews(myMapView, sublayersButton);
        }