Ejemplo n.º 1
0
        private async void Initialize()
        {
            // Get the offline tile package and use it as a basemap.
            string           basemapPath       = DataManager.GetDataFolder("1330ab96ac9c40a49e59650557f2cd63", "streetmap_SD.tpk");
            ArcGISTiledLayer tiledBasemapLayer = new ArcGISTiledLayer(new TileCache(basemapPath));

            // Create new Map with basemap.
            Map myMap = new Map(new Basemap(tiledBasemapLayer));

            // Provide Map to the MapView.
            _myMapView.Map = myMap;

            // Add a graphics overlay for showing pins.
            _myMapView.GraphicsOverlays.Add(new GraphicsOverlay());

            try
            {
                // Get the path to the locator.
                string locatorPath = DataManager.GetDataFolder("344e3b12368543ef84045ef9aa3c32ba", "san-diego-locator.loc");

                // Load the geocoder.
                _geocoder = await LocatorTask.CreateAsync(new Uri(locatorPath));

                // Enable controls now that the geocoder is ready.
                _addressSearchBar.UserInteractionEnabled = true;
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
Ejemplo n.º 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;
        }
        private void Initialize()
        {
            // Create the public layer and provide a name
            var publicLayer = new ArcGISTiledLayer(new Uri(PublicMapServiceUrl));
            publicLayer.Name = PublicLayerName;

            // Set the data context for the public layer stack panel controls (to report name and load status)
            PublicLayerPanel.DataContext = publicLayer;

            // Create the secured layer and provide a name
            var tokenSecuredLayer = new ArcGISMapImageLayer(new Uri(SecureMapServiceUrl));
            tokenSecuredLayer.Name = SecureLayerName;

            // Set the data context for the secure layer stack panel controls (to report name and load status)
            SecureLayerPanel.DataContext = tokenSecuredLayer;

            // Create a new map and add the layers
            var myMap = new Map();
            myMap.OperationalLayers.Add(publicLayer);
            myMap.OperationalLayers.Add(tokenSecuredLayer);
            var t = new TextBlock();

            // Add the map to the map view
            MyMapView.Map = myMap;
        }
        private void Initialize()
        {
            // Create new Map
            Map myMap = new Map();

            // Create the uri for the tiled layer
            Uri tiledLayerUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer");

            // Create a tiled layer using url
            ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tiledLayerUri);
            tiledLayer.Name = "Tiled Layer";

            // Add the tiled layer to map
            myMap.OperationalLayers.Add(tiledLayer);

            // Create the uri for the ArcGISMapImage layer
            var imageLayerUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer");

            // Create ArcGISMapImage layer using a url
            ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(imageLayerUri);
            imageLayer.Name = "Image Layer";

            // Set the visible scale range for the image layer
            imageLayer.MinScale = 40000000;
            imageLayer.MaxScale = 2000000;

            // Add the image layer to map
            myMap.OperationalLayers.Add(imageLayer);

            //Create Uri for feature layer
            var featureLayerUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0");

            //Create a feature layer using url
            FeatureLayer myFeatureLayer = new FeatureLayer(featureLayerUri);
            myFeatureLayer.Name = "Feature Layer";

            // Add the feature layer to map
            myMap.OperationalLayers.Add(myFeatureLayer);

            // Create a mappoint the map should zoom to
            MapPoint mapPoint = new MapPoint(-11000000, 4500000, SpatialReferences.WebMercator);

            // Set the initial viewpoint for map
            myMap.InitialViewpoint = new Viewpoint(mapPoint, 50000000);

            // Initialize the model list with unknown status for each layer
            foreach (Layer layer in myMap.OperationalLayers)
            {
                _layerStatusModels.Add(new LayerStatusModel(layer.Name, "Unknown"));
            }

            // Create the tableview source and pass the list of models to it
            _tableView.Source = new LayerViewStatusTableSource(_layerStatusModels);

            // Event for layer view state changed
            _myMapView.LayerViewStateChanged += OnLayerViewStateChanged;

            // Provide used Map to the MapView
            _myMapView.Map = myMap;
        }
Ejemplo n.º 5
0
        private void Initialize()
        {
            // Create new Map
            Map myMap = new Map();

            // Create the uri for the tiled layer
            Uri tiledLayerUri = new Uri(
                "https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer");

            // Create a tiled layer using url
            ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tiledLayerUri)
            {
                Name = "Tiled Layer"
            };

            // Add the tiled layer to map
            myMap.OperationalLayers.Add(tiledLayer);

            // Create the uri for the ArcGISMapImage layer
            Uri imageLayerUri = new Uri(
                "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer");

            // Create ArcGISMapImage layer using a url
            ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(imageLayerUri)
            {
                Name = "Image Layer",

                // Set the visible scale range for the image layer
                MinScale = 40000000,
                MaxScale = 2000000
            };

            // Add the image layer to map
            myMap.OperationalLayers.Add(imageLayer);

            // Create Uri for feature layer
            Uri featureLayerUri = new Uri(
                "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0");

            // Create a feature layer using url
            FeatureLayer myFeatureLayer = new FeatureLayer(featureLayerUri)
            {
                Name = "Feature Layer"
            };

            // Add the feature layer to map
            myMap.OperationalLayers.Add(myFeatureLayer);

            // Create a map point the map should zoom to
            MapPoint mapPoint = new MapPoint(-11000000, 4500000, SpatialReferences.WebMercator);

            // Set the initial viewpoint for map
            myMap.InitialViewpoint = new Viewpoint(mapPoint, 50000000);

            // Event for layer view state changed
            MyMapView.LayerViewStateChanged += OnLayerViewStateChanged;

            // Provide used Map to the MapView
            MyMapView.Map = myMap;
        }
Ejemplo n.º 6
0
        private async void Initialize()
        {
            // Define a challenge handler method for the AuthenticationManager
            // (this method handles getting credentials when a secured resource is encountered)
            AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(CreateKnownCredentials);

            // Create the public layer and provide a name
            var publicLayer = new ArcGISTiledLayer(new Uri(PublicMapServiceUrl));

            publicLayer.Name = PublicLayerName;

            // Create the secured layer and provide a name
            var tokenSecuredLayer = new ArcGISMapImageLayer(new Uri(SecureMapServiceUrl));

            tokenSecuredLayer.Name = SecureLayerName;

            // Bind the layer to UI controls to show the load status
            PublicLayerStatusPanel.BindingContext = publicLayer;
            SecureLayerStatusPanel.BindingContext = tokenSecuredLayer;

            // Create a new map and add the layers
            var myMap = new Map();

            myMap.OperationalLayers.Add(publicLayer);
            myMap.OperationalLayers.Add(tokenSecuredLayer);

            // Add the map to the map view
            MyMapView.Map = myMap;
        }
Ejemplo n.º 7
0
        private async void InitMap()
        {
            //지도위치 및 스케일 초기화
            await mapView.SetViewpointCenterAsync(_ulsanCoords, _ulsanScale);

            //Base맵 초기화
            Console.WriteLine("this._map.SpatialReference - " + this._map.SpatialReference);
            //this._map.Basemap = Basemap.CreateOpenStreetMap();

            //타일맵
            TileCache        tileCache = new TileCache(BizUtil.GetDataFolder("tile", "korea.tpk"));
            ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache);

            this._map.Basemap = new Basemap(tileLayer);


            //울산행정구역표시
            ShowShapeLayer(mapView, "BML_GADM_AS", true);


            //맵뷰 클릭이벤트 설정
            mapView.GeoViewTapped -= handlerGeoViewTappedMoveFeature;
            mapView.GeoViewTapped -= handlerGeoViewTappedAddFeature;
            mapView.GeoViewTapped -= handlerGeoViewTapped;
            mapView.GeoViewTapped += handlerGeoViewTapped;


            // Create graphics overlay to display sketch geometry
            _sketchOverlay = new GraphicsOverlay();
            mapView.GraphicsOverlays.Add(_sketchOverlay);
        }
        private async void Initialize()
        {
            // Create the tile layer
            ArcGISTiledLayer myLayer = new ArcGISTiledLayer(_serviceUri);

            // Load the layer
            await myLayer.LoadAsync();

            // Create the basemap with the layer
            _basemap = new Map(new Basemap(myLayer));

            // Assign the map to the mapview
            MyMapView.Map = _basemap;

            // Create a new symbol for the extent graphic
            //     This is the red box that visualizes the extent for which tiles will be exported
            SimpleLineSymbol myExtentSymbol = 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(myExtentSymbol);

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

            // Subscribe to changes in the mapview's viewpoint so the preview box can be kept in position
            MyMapView.ViewpointChanged += MyMapView_ViewpointChanged;
        }
        private void Initialize()
        {
            // Create the public layer and provide a name.
            var publicLayer = new ArcGISTiledLayer(new Uri(_publicMapServiceUrl))
            {
                Name = _publicLayerName
            };

            // Set the data context for the public layer stack panel controls (to report name and load status).
            PublicLayerPanel.DataContext = publicLayer;

            // Create the secured layer and provide a name.
            var tokenSecuredLayer = new ArcGISMapImageLayer(new Uri(_secureMapServiceUrl))
            {
                Name = _secureLayerName
            };

            // Set the data context for the secure layer stack panel controls (to report name and load status).
            SecureLayerPanel.DataContext = tokenSecuredLayer;

            // Create a new map and add the layers.
            var myMap = new Map();

            myMap.OperationalLayers.Add(publicLayer);
            myMap.OperationalLayers.Add(tokenSecuredLayer);

            // Add the map to the map view.
            MyMapView.Map = myMap;
        }
Ejemplo n.º 10
0
        public async Task <Map> GetMap()
        {
            if (_config.usetileCache)
            {
                var imageryTiledLayer = new ArcGISTiledLayer(new Uri(_config.basemap));
                Map map = new Map();
                map.Basemap = new Basemap(imageryTiledLayer);
                return(map);
            }

            try
            {
                var Portal = await ArcGISPortal.CreateAsync(new Uri(_config.webMap.url));

                PortalItem webMapItem = null;
                webMapItem = await PortalItem.CreateAsync(Portal, _config.webMap.item);

                Map map = new Map(webMapItem);
                return(map);
            }
            catch (Exception ex)
            {
                throw new Exception($"Kan ikke laste kart; Portal inneholder ikke WebMap med Id {_config.webMap.item}: {ex.Message}");
            }
        }
        private void Initialize()
        {
            // Define a challenge handler method for the AuthenticationManager.
            // This method handles getting credentials when a secured resource is encountered.
            AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(CreateKnownCredentials);

            // Create the public layer and provide a name.
            var publicLayer = new ArcGISTiledLayer(new Uri(_publicMapServiceUrl))
            {
                Name = _publicLayerName
            };

            // Create the secured layer and provide a name.
            var tokenSecuredLayer = new ArcGISMapImageLayer(new Uri(_secureMapServiceUrl))
            {
                Name = _secureLayerName
            };

            // Track the load status of each layer with a LoadStatusChangedEvent handler.
            publicLayer.LoadStatusChanged       += LayerLoadStatusChanged;
            tokenSecuredLayer.LoadStatusChanged += LayerLoadStatusChanged;

            // Create a new map and add the layers.
            var myMap = new Map();

            myMap.OperationalLayers.Add(publicLayer);
            myMap.OperationalLayers.Add(tokenSecuredLayer);

            // Add the map to the map view.
            _myMapView.Map = myMap;
        }
Ejemplo n.º 12
0
        private async void Load()
        {
            //"https://arc5.thevillages.com/arcgis/rest/services/TSGLOCATE2/GeocodeServer"
            //string geo = Application.Current.Resources["GeoCodeServer"] as string;
            //_geocoder = new LocatorTask(new Uri(geo));
            //await _geocoder.LoadAsync();
            string ms = "https://arc7.thevillages.com/arcgis/rest/services/PUBLICMAP26W/MapServer";
            //string ms = Application.Current.Resources["MapServer"] as string;
            Uri mapService = new Uri(ms);

            var layer = new ArcGISTiledLayer(mapService);

            Map = new Esri.ArcGISRuntime.Mapping.Map(new Basemap(layer));

            double scale = 24000d;

            if (Destination == null)
            {
                scale       = 200000d;
                Destination = _theVillagesCentralPoint;
            }
            Viewpoint startingPoint = new Viewpoint(Destination, scale);

            Map.InitialViewpoint = startingPoint;

            await Map.LoadAsync();
        }
        private async void Initialize()
        {
            // Define a challenge handler method for the AuthenticationManager 
            // (this method handles getting credentials when a secured resource is encountered)
            AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(CreateKnownCredentials);

            // Create the public layer and provide a name
            var publicLayer = new ArcGISTiledLayer(new Uri(PublicMapServiceUrl));
            publicLayer.Name = PublicLayerName;

            // Create the secured layer and provide a name
            var tokenSecuredLayer = new ArcGISMapImageLayer(new Uri(SecureMapServiceUrl));
            tokenSecuredLayer.Name = SecureLayerName;

            // Bind the layer to UI controls to show the load status
            PublicLayerStatusPanel.BindingContext = publicLayer;
            SecureLayerStatusPanel.BindingContext = tokenSecuredLayer;

            // Create a new map and add the layers
            var myMap = new Map();
            myMap.OperationalLayers.Add(publicLayer);
            myMap.OperationalLayers.Add(tokenSecuredLayer);

            // Add the map to the map view
            MyMapView.Map = myMap;
        }
        private async void Initialize()
        {
            // Define a challenge handler method for the AuthenticationManager 
            // (this method handles getting credentials when a secured resource is encountered)
            AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(CreateCredentialAsync);

            // Create the public layer and provide a name
            var publicLayer = new ArcGISTiledLayer(new Uri(PublicMapServiceUrl));
            publicLayer.Name = PublicLayerName;             

            // Create the secured layer and provide a name
            var tokenSecuredLayer = new ArcGISMapImageLayer(new Uri(SecureMapServiceUrl));
            tokenSecuredLayer.Name = SecureLayerName;

            // Bind the layer to UI controls to show the load status
            PublicLayerStatusPanel.BindingContext = publicLayer;
            SecureLayerStatusPanel.BindingContext = tokenSecuredLayer;
            
            // Create a new map and add the layers
            var myMap = new Map();
            myMap.OperationalLayers.Add(publicLayer);
            myMap.OperationalLayers.Add(tokenSecuredLayer);

            // Add the map to the map view
            MyMapView.Map = myMap;

            // Create the login UI (will display when the user accesses a secured resource)
            _loginPage = new LoginPage();

            // Set up event handlers for when the user completes the login entry or cancels
            _loginPage.OnLoginInfoEntered += LoginInfoEntered;
            _loginPage.OnCanceled += LoginCanceled;
        }
Ejemplo n.º 15
0
        private async void InitMap()
        {
            //지도위치 및 스케일 초기화
            await mapView.SetViewpointCenterAsync(GisCmm._hsCoords, GisCmm._ulsanScale2);

            //Base맵 초기화
            Console.WriteLine("this._map.SpatialReference - " + this._map.SpatialReference);
            //this._map.Basemap = Basemap.CreateOpenStreetMap();

            //타일맵
            //TileCache tileCache = new TileCache(BizUtil.GetDataFolder("tile", "korea.tpk"));
            string           tile_paht = @"c:\GTI\korea.tpk";
            TileCache        tileCache = new TileCache(tile_paht);
            ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache);

            this._map.Basemap = new Basemap(tileLayer);



            //맵뷰 클릭이벤트 설정
            mapView.GeoViewTapped -= handlerGeoViewTappedMoveFeature;
            mapView.GeoViewTapped -= handlerGeoViewTappedAddFeature;
            mapView.GeoViewTapped -= handlerGeoViewTapped;
            mapView.GeoViewTapped += handlerGeoViewTapped;


            // Create graphics overlay to display sketch geometry
            _sketchOverlay = new GraphicsOverlay();
            mapView.GraphicsOverlays.Add(_sketchOverlay);
        }
        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));
                }
            }
        }
Ejemplo n.º 17
0
        public MapViewModel()
        {
            string url = "https://services2.geodataonline.no/arcgis/rest/services/Geocache_UTM33_EUREF89/GeocacheBasis/MapServer";
            //url = "https://services.geodataonline.no/arcgis/rest/services/Geocache_WMAS_WGS84/GeocacheBasis/MapServer";
            var imageryTiledLayer = new ArcGISTiledLayer(new Uri(url));

            // create a basemap from the tiled layer
            _map.Basemap = new Basemap(imageryTiledLayer);
        }
        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;
        }
        private async Task UpdatePreviewMap(TileCache cache)
        {
            // Load the cache.
            await cache.LoadAsync();

            // Create a tile layer from the tile cache.
            ArcGISTiledLayer myLayer = new ArcGISTiledLayer(cache);

            // Show the layer in a new map.
            MyPreviewMapView.Map = new Map(new Basemap(myLayer));
        }
        private void Initialize()
        {
            // Create new Map
            Map myMap = new Map();

            // Create the uri for the tiled layer
            var tiledLayerUri = new Uri(
                "http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer");

            // Create a tiled layer using url
            ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tiledLayerUri);
            tiledLayer.Name = "Tiled Layer";

            // Add the tiled layer to map
            myMap.OperationalLayers.Add(tiledLayer);

            // Create the uri for the ArcGISMapImage layer
            var imageLayerUri = new Uri(
                "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer");

            // Create ArcGISMapImage layer using a url
            ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(imageLayerUri);
            imageLayer.Name = "Image Layer";

            // Set the visible scale range for the image layer
            imageLayer.MinScale = 40000000;
            imageLayer.MaxScale = 2000000;

            // Add the image layer to map
            myMap.OperationalLayers.Add(imageLayer);

            // Create Uri for feature layer
            var featureLayerUri = new Uri(
                "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0");

            // Create a feature layer using url
            FeatureLayer myFeatureLayer = new FeatureLayer(featureLayerUri);
            myFeatureLayer.Name = "Feature Layer";

            // Add the feature layer to map
            myMap.OperationalLayers.Add(myFeatureLayer);

            // Create a map point the map should zoom to
            MapPoint mapPoint = new MapPoint(-11000000, 4500000, SpatialReferences.WebMercator);

            // Set the initial viewpoint for map
            myMap.InitialViewpoint = new Viewpoint(mapPoint, 50000000);

            // Event for layer view state changed
            MyMapView.LayerViewStateChanged += OnLayerViewStateChanged;

            // Provide used Map to the MapView
            MyMapView.Map = myMap;
        }
Ejemplo n.º 21
0
        private async Task UpdatePreviewMap(TileCache cache)
        {
            // Load the cache.
            await cache.LoadAsync();

            // Create a tile layer with the cache.
            ArcGISTiledLayer myLayer = new ArcGISTiledLayer(cache);

            // Apply the map to the preview mapview.
            MyPreviewMapView.Map = new Map(new Basemap(myLayer));
        }
        private async Task UpdatePreviewMap(TileCache cache)
        {
            // Load the cache.
            await cache.LoadAsync();

            // Create a tile layer with the cache.
            ArcGISTiledLayer myLayer = new ArcGISTiledLayer(cache);

            // Show the exported tiles in new map.
            _myPreviewMapView.Map = new Map(new Basemap(myLayer));
        }
Ejemplo n.º 23
0
        private async void Initialize()
        {
            // Create the tile layer.
            try
            {
                ArcGISTiledLayer myLayer = new ArcGISTiledLayer(_serviceUri);

                // Load the layer.
                await myLayer.LoadAsync();

                // Create the basemap with the layer.
                Map myMap = new Map(new Basemap(myLayer))
                {
                    // Set the min and max scale - export task fails if the scale is too big or small.
                    MaxScale = 5000000,
                    MinScale = 10000000
                };

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

                // Create a new symbol for the extent graphic.
                //     This is the red box that visualizes the extent for which tiles will be exported.
                SimpleLineSymbol myExtentSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2);

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

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

                // Subscribe to changes in the mapview's viewpoint so the preview box can be kept in position.
                MyMapView.ViewpointChanged += MyMapView_ViewpointChanged;

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

                // Enable the export tile button once sample is ready.
                MyExportButton.IsEnabled = true;

                // Set viewpoint of the map.
                MyMapView.SetViewpoint(new Viewpoint(-4.853791, 140.983598, myMap.MinScale));
            }
            catch (Exception ex)
            {
                ShowStatusMessage(ex.ToString());
            }
        }
        /// <summary>
        /// Will build the list of tpks inside local state folder and upate view of dialog with it.
        /// </summary>
        public async void GetFiles()
        {
            //Clear current
            _filenameValues.Clear();

            // Get list of TPK files in, for the time being, the localFolder - this is not ideal
            StorageFolder localFolder            = ApplicationData.Current.LocalFolder;
            IReadOnlyList <StorageFile> fileList = await localFolder.GetFilesAsync();

            List <string> mapLayers = new List <string>();

            foreach (var layer in esriMap.AllLayers)
            {
                mapLayers.Add(layer.Name);
            }

            foreach (StorageFile file in fileList)
            {
                if (file.FileType.ToLower() == ".tpk")
                {
                    if (!mapLayers.Contains(Path.GetFileNameWithoutExtension(file.Name)))
                    {
                        var localUri = new Uri("file:\\" + file.Path);

                        _basemapLayer = new ArcGISTiledLayer(localUri);

                        await _basemapLayer.LoadAsync();

                        if (_basemapLayer.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
                        {
                            _basemapLayer.IsVisible = true;
                            esriMap.Basemap.BaseLayers.Add(_basemapLayer);
                        }
                    }
                }
            }

            // Create cells for each of the sublayers
            foreach (ArcGISTiledLayer sublayer in esriMap.AllLayers)
            {
                Files layerFile = new Files();
                layerFile.FileName    = sublayer.Name;
                layerFile.FileVisible = sublayer.IsVisible;
                layerFile.FilePath    = sublayer.Source.OriginalString;

                //Reverse order on screen to match what is available in SIG usually
                _filenameValues.Insert(0, layerFile);
            }

            RaisePropertyChanged("FilenameValues");
        }
Ejemplo n.º 25
0
        private async Task UpdatePreviewMap(TileCache cache)
        {
            // Load the cache.
            await cache.LoadAsync();

            // Create a tile layer with the cache.
            ArcGISTiledLayer myLayer = new ArcGISTiledLayer(cache);

            // Show the tiles in a new map.
            _myMapView.Map = new Map(new Basemap(myLayer));

            // Set the margin.
            SetMapviewMargin(40);
        }
        private async Task UpdatePreviewMap(TileCache cache)
        {
            // Load the cache.
            await cache.LoadAsync();

            // Create a tile layer with the cache.
            ArcGISTiledLayer myLayer = new ArcGISTiledLayer(cache);

            // Show the layer in a new map.
            MyMapView.Map = new Map(new Basemap(myLayer));

            // Re-size the mapview.
            MyMapView.Margin = new Thickness(40);
        }
        /// <summary>
        /// Will set the maps (layers) order in the map control from user choices.
        /// </summary>
        public void SetOrder()
        {
            esriMap.Basemap.BaseLayers.Clear();
            foreach (Files orderedFiles in _filenameValues.Reverse()) //Reverse order while iteration because UI is reversed intentionnaly
            {
                //Build path
                Uri localUri = new Uri(orderedFiles.FilePath);

                //Build tile layer
                ArcGISTiledLayer orderedLayer = new ArcGISTiledLayer(localUri);
                orderedLayer.IsVisible = orderedFiles.FileVisible;
                orderedLayer.Name      = orderedFiles.FileName;
                esriMap.Basemap.BaseLayers.Add(orderedLayer);
            }
        }
Ejemplo n.º 28
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));
                }
            }
        }
Ejemplo n.º 29
0
        public void Initialize()
        {
            myMap = new Map();

            TileCache        tileCache  = new TileCache(@"D:\workshops\offlinemap-app-hands-on\samples\SampleData\public_map.tpk");
            ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tileCache);

            LayerCollection baseLayers = new LayerCollection();

            baseLayers.Add(tiledLayer);
            myMap.Basemap.BaseLayers = baseLayers;

            // 主題図の表示
            addFeatureLayer();

            MyMapView.Map = myMap;
        }
Ejemplo n.º 30
0
        private void Initialize()
        {
            // Create new Map.
            Map map = new Map();

            // Create URI to the tiled service.
            Uri serviceUri = new Uri("https://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer");

            // Create new tiled layer from the URL.
            ArcGISTiledLayer imageLayer = new ArcGISTiledLayer(serviceUri);

            // Add created layer to the basemaps collection.
            map.Basemap.BaseLayers.Add(imageLayer);

            // Assign the map to the MapView.
            _myMapView.Map = map;
        }
        /// <summary>
        /// Loads the tile cache from disk and displays it in the preview map
        /// </summary>
        private async void UpdatePreviewMap()
        {
            // Load the saved tile cache
            TileCache cache = new TileCache(_tilePath);

            // Load the cache
            await cache.LoadAsync();

            // Create a tile layer with the cache
            ArcGISTiledLayer myLayer = new ArcGISTiledLayer(cache);

            // Create a new map with the layer as basemap
            Map previewMap = new Map(new Basemap(myLayer));

            // Apply the map to the preview mapview
            MyPreviewMapView.Map = previewMap;
        }
Ejemplo n.º 32
0
        private async void Initialize()
        {
            try
            {
                // Create the tile layer.
                ArcGISTiledLayer myLayer = new ArcGISTiledLayer(_serviceUri);

                // Load the layer.
                await myLayer.LoadAsync();

                // Create and show the basemap with the layer.
                _myMapView.Map = new Map(new Basemap(myLayer))
                {
                    // Set the min and max scale - export task fails if the scale is too big or small.
                    MaxScale = 5000000,
                    MinScale = 10000000
                };

                // Create a new symbol for the extent graphic.
                //     This is the red box that visualizes the extent for which tiles will be exported.
                SimpleLineSymbol myExtentSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2);

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

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

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

                // Enable the export button now that sample is ready.
                _exportTilesButton.Enabled = true;

                // Set viewpoint of the map.
                _myMapView.SetViewpoint(new Viewpoint(-4.853791, 140.983598, _myMapView.Map.MinScale));
            }
            catch (Exception ex)
            {
                ShowStatusMessage(ex.ToString());
            }
        }
        private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            var map = new Map(BasemapType.DarkGrayCanvasVector, 39.8283, -98.5795, 5);

            //add map image layer
            var mapImageUri = new Uri("http://sampleserver5.arcgisonline.com/arcgis/rest/services/Elevation/WorldElevations/MapServer");
            ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(mapImageUri);

            map.OperationalLayers.Add(imageLayer);

            //add map tiled layer
            var tileUri = new Uri("http://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer");
            ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tileUri);

            map.OperationalLayers.Add(tiledLayer);

            //add vector tile layer
            var vectorUri = new Uri("http://www.arcgis.com/home/item.html?id=75f4dfdff19e445395653121a95a85db");
            ArcGISVectorTiledLayer vector = new ArcGISVectorTiledLayer(vectorUri);

            map.OperationalLayers.Add(vector);

            //add raster layer
            var rasterUri = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover2001/ImageServer");
            ImageServiceRaster rasterService = new ImageServiceRaster(rasterUri); // Create new image service raster from the Uri
            await rasterService.LoadAsync();                                      // Load the image service raster

            RasterLayer raster = new RasterLayer(rasterService);                  // Create a new raster layer from the image service raster

            map.OperationalLayers.Add(raster);                                    // Add the raster layer to the maps layer collection

            //Add feature layer us cities
            var          featUri  = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0");
            FeatureLayer usCities = new FeatureLayer(featUri);

            map.OperationalLayers.Add(usCities);

            //add feature layer world cities
            var          featUri1    = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer/0");
            FeatureLayer worldCities = new FeatureLayer(featUri1);

            map.OperationalLayers.Add(worldCities);

            MyMapView.Map = map;
        }
Ejemplo n.º 34
0
        public MainWindow()
        {
            Items       = new ObservableCollection <string>();
            DataContext = this;
            Esri.ArcGISRuntime.Http.ArcGISHttpClientHandler.HttpRequestBegin += ArcGISHttpClientHandler_HttpRequestBegin;
            InitializeComponent();

            string url = "https://services2.geodataonline.no/arcgis/rest/services/Geocache_UTM33_EUREF89/GeocacheBasis/MapServer";
            //url = "https://services.geodataonline.no/arcgis/rest/services/Geocache_WMAS_WGS84/GeocacheBasis/MapServer";
            var imageryTiledLayer = new ArcGISTiledLayer(new Uri(url));

            // create a basemap from the tiled layer

            _map.Basemap  = new Basemap(imageryTiledLayer);
            MyMapView.Map = _map;
            MyMapView.DrawStatusChanged += MyMapView_DrawStatusChanged;
            BuildZoomAreas();
        }
        private void Initialize()
        {
            // Create new Map
            Map myMap = new Map();

            // Create uri to the tiled service
            var serviceUri = new Uri(
               "http://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer");

            // Create new tiled layer from the url
            ArcGISTiledLayer imageLayer = new ArcGISTiledLayer(serviceUri);

            // Add created layer to the basemaps collection
            myMap.Basemap.BaseLayers.Add(imageLayer);

            // Assign the map to the MapView
            _myMapView.Map = myMap;
        }
        private async Task UpdatePreviewMap(TileCache cache)
        {
            // Load the cache.
            await cache.LoadAsync();

            // Create a tile layer with the cache.
            ArcGISTiledLayer myLayer = new ArcGISTiledLayer(cache);

            // Show the exported tiles in new map.
            var vc         = new UIViewController();
            Map previewMap = new Map();

            previewMap.OperationalLayers.Add(myLayer);
            vc.View = new MapView {
                Map = previewMap
            };
            vc.Title = "Exported tiles";
            NavigationController.PushViewController(vc, true);
        }
        private void Initialize()
        {
            // Define a challenge handler method for the AuthenticationManager 
            // (this method handles getting credentials when a secured resource is encountered)
            AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(CreateCredentialAsync);

            // Create the public layer and provide a name
            var publicLayer = new ArcGISTiledLayer(new Uri(PublicMapServiceUrl));
            publicLayer.Name = PublicLayerName;

            // Create the secured layer and provide a name
            var tokenSecuredLayer = new ArcGISMapImageLayer(new Uri(SecureMapServiceUrl));
            tokenSecuredLayer.Name = SecureLayerName;

            // Track the load status of each layer with a LoadStatusChangedEvent handler
            publicLayer.LoadStatusChanged += LayerLoadStatusChanged;
            tokenSecuredLayer.LoadStatusChanged += LayerLoadStatusChanged;

            // Create a new map and add the layers
            var myMap = new Map();
            myMap.OperationalLayers.Add(publicLayer);
            myMap.OperationalLayers.Add(tokenSecuredLayer);

            // Add the map to the map view
            _myMapView.Map = myMap;
        }