private void BasemapCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                int index = BasemapCombobox.SelectedIndex;
                switch (index)
                {
                case 0:
                    MyMapView.Map.Basemap = Basemap.CreateStreetsVector();
                    break;

                case 1:
                    MyMapView.Map.Basemap = Basemap.CreateTopographicVector();
                    break;

                case 2:
                    MyMapView.Map.Basemap = Basemap.CreateImageryWithLabelsVector();
                    break;

                case 3:
                    MyMapView.Map.Basemap = Basemap.CreateStreetsNightVector();
                    break;

                default:
                    MyMapView.Map.Basemap = Basemap.CreateOpenStreetMap();
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private async void Initialize()
        {
            try
            {
                // Update interface state.
                UpdateInterfaceState(SampleState.NotReady);

                // Create the map with a basemap.
                Map sampleMap = new Map(Basemap.CreateTopographicVector());
                sampleMap.InitialViewpoint = new Viewpoint(32.7157, -117.1611, 1e5);
                _myMapView.Map             = sampleMap;

                // Create the graphics overlays. These will manage rendering of route, direction, stop, and barrier graphics.
                _routeOverlay    = new GraphicsOverlay();
                _stopsOverlay    = new GraphicsOverlay();
                _barriersOverlay = new GraphicsOverlay();

                // Add graphics overlays to the map view.
                _myMapView.GraphicsOverlays.Add(_routeOverlay);
                _myMapView.GraphicsOverlays.Add(_stopsOverlay);
                _myMapView.GraphicsOverlays.Add(_barriersOverlay);

                // Create and initialize the route task.
                _routeTask = await RouteTask.CreateAsync(new Uri(RouteServiceUrl));

                // Get the route parameters from the route task.
                _routeParameters = await _routeTask.CreateDefaultParametersAsync();

                // Prepare symbols.
                _routeSymbol   = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Blue, 2);
                _barrierSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Cross, Color.Red, null);

                // Configure directions display.
                _directionsViewModel = new DirectionsViewModel(_directions);

                // Create the table view controller for displaying directions.
                _directionsController = new UITableViewController(UITableViewStyle.Plain);

                // The table view content is managed by the view model.
                _directionsController.TableView.Source = _directionsViewModel;

                // Create the view controller for configuring the route.
                _routeSettingsController = new RouteSettingsViewController();

                // Enable the UI.
                UpdateInterfaceState(SampleState.Ready);
            }
            catch (Exception e)
            {
                UpdateInterfaceState(SampleState.NotReady);
                System.Diagnostics.Debug.WriteLine(e);
                ShowMessage("Couldn't load sample", "Couldn't start the sample. See the debug output for detail.");
            }
        }
Beispiel #3
0
        public static Basemap FromBasemapType(this BasemapType type)
        {
            switch (type)
            {
            case BasemapType.DarkGrayCanvasVector: return(Basemap.CreateDarkGrayCanvasVector());

            case BasemapType.Imagery: return(Basemap.CreateImagery());

            case BasemapType.ImageryWithLabels: return(Basemap.CreateImageryWithLabels());

            case BasemapType.ImageryWithLabelsVector: return(Basemap.CreateImageryWithLabelsVector());

            case BasemapType.LightGrayCanvas: return(Basemap.CreateLightGrayCanvas());

            case BasemapType.LightGrayCanvasVector: return(Basemap.CreateLightGrayCanvasVector());

            case BasemapType.NationalGeographic: return(Basemap.CreateNationalGeographic());

            case BasemapType.NavigationVector: return(Basemap.CreateNavigationVector());

            case BasemapType.Oceans: return(Basemap.CreateOceans());

            case BasemapType.OpenStreetMap: return(Basemap.CreateOpenStreetMap());

            case BasemapType.Streets: return(Basemap.CreateStreets());

            case BasemapType.StreetsNightVector: return(Basemap.CreateStreetsNightVector());

            case BasemapType.StreetsVector: return(Basemap.CreateStreetsVector());

            case BasemapType.StreetsWithReliefVector: return(Basemap.CreateStreetsWithReliefVector());

            case BasemapType.TerrainWithLabels: return(Basemap.CreateTerrainWithLabels());

            case BasemapType.TerrainWithLabelsVector: return(Basemap.CreateTerrainWithLabelsVector());

            case BasemapType.Topographic: return(Basemap.CreateTopographic());

            case BasemapType.TopographicVector: return(Basemap.CreateTopographicVector());

            default: throw new NotImplementedException(type.ToString());
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MapViewModel"/> class.
        /// </summary>
        public MapViewModel()
        {
            LocationDataSource = new SystemLocationDataSource();
            LocationDataSource.LocationChanged += (s, l) =>
            {
                _lastLocation = l;
            };

            // reset map if user is signed out
            AuthViewModel.Instance.PropertyChanged += (s, l) =>
            {
                if (l.PropertyName == nameof(AuthViewModel.AuthenticatedUser) && AuthViewModel.Instance.AuthenticatedUser == null)
                {
                    Map = new Map(Basemap.CreateTopographicVector())
                    {
                        InitialViewpoint = AreaOfInterest
                    };
                }
            };
        }
Beispiel #5
0
        public void ChangeBasemap(string basemap)
        {
            // Apply the selected basemap to the map
            switch (basemap)
            {
            case "Topographic":
                // Set the basemap to Topographic
                _map.Basemap = Basemap.CreateTopographic();
                break;

            case "Topographic Vector":
                // Set the basemap to Topographic (vector)
                _map.Basemap = Basemap.CreateTopographicVector();
                break;

            case "Streets":
                // Set the basemap to Streets
                _map.Basemap = Basemap.CreateStreets();
                break;

            case "Streets Vector":
                // Set the basemap to Streets (vector)
                _map.Basemap = Basemap.CreateStreetsVector();
                break;

            case "Imagery":
                // Set the basemap to Imagery
                _map.Basemap = Basemap.CreateImagery();
                break;

            case "Oceans":
                // Set the basemap to Oceans
                _map.Basemap = Basemap.CreateOceans();
                break;
            }
        }
        private async void Initialize()
        {
            try
            {
                // Create the utility network.
                _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServerUrl));

                // Create the map.
                _myMapView.Map = new Map(Basemap.CreateTopographicVector());

                // Get all of the edges and junctions in the network.
                IEnumerable <UtilityNetworkSource> edges     = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Edge);
                IEnumerable <UtilityNetworkSource> junctions = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Junction);

                // Add all edges that are not subnet lines to the map.
                foreach (UtilityNetworkSource source in edges)
                {
                    if (source.SourceUsageType != UtilityNetworkSourceUsageType.SubnetLine && source.FeatureTable != null)
                    {
                        _myMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable));
                    }
                }

                // Add all junctions to the map.
                foreach (UtilityNetworkSource source in junctions)
                {
                    if (source.FeatureTable != null)
                    {
                        _myMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable));
                    }
                }

                // Create a graphics overlay for associations.
                _associationsOverlay = new GraphicsOverlay();
                _myMapView.GraphicsOverlays.Add(_associationsOverlay);

                // Symbols for the associations.
                Symbol attachmentSymbol   = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Green, 5d);
                Symbol connectivitySymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Red, 5d);

                // Create a renderer for the associations.
                var attachmentValue   = new UniqueValue("Attachment", string.Empty, attachmentSymbol, UtilityAssociationType.Attachment.ToString());
                var connectivityValue = new UniqueValue("Connectivity", string.Empty, connectivitySymbol, UtilityAssociationType.Connectivity.ToString());
                _associationsOverlay.Renderer = new UniqueValueRenderer(new List <string> {
                    "AssociationType"
                }, new List <UniqueValue> {
                    attachmentValue, connectivityValue
                }, string.Empty, null);

                // Populate the legend in the UI.
                RuntimeImage attachmentSwatch = await attachmentSymbol.CreateSwatchAsync();

                Android.Graphics.Bitmap attachmentBitmap = await attachmentSwatch?.ToImageSourceAsync();

                _attachmentImageView.SetImageBitmap(attachmentBitmap);

                RuntimeImage connectSwatch = await connectivitySymbol.CreateSwatchAsync();

                Android.Graphics.Bitmap connectivityBitmap = await connectSwatch?.ToImageSourceAsync();

                _connectivityImageView.SetImageBitmap(connectivityBitmap);

                // Set the starting viewpoint.
                await _myMapView.SetViewpointAsync(InitialViewpoint);

                // Add the associations in the starting viewpoint.
                AddAssociations();
            }
            catch (Exception ex)
            {
                new AlertDialog.Builder(this).SetMessage(ex.Message).SetTitle(ex.GetType().Name).Show();
            }
        }
Beispiel #7
0
        private async void Initialize()
        {
            // As of ArcGIS Enterprise 10.8.1, using utility network functionality requires a licensed user. The following login for the sample server is licensed to perform utility network operations.
            AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(async(info) =>
            {
                try
                {
                    // WARNING: Never hardcode login information in a production application. This is done solely for the sake of the sample.
                    string sampleServer7User = "******";
                    string sampleServer7Pass = "******";
                    return(await AuthenticationManager.Current.GenerateCredentialAsync(info.ServiceUri, sampleServer7User, sampleServer7Pass));
                }
                catch (Exception ex)
                {
                    await new MessageDialog2(ex.Message, ex.Message.GetType().Name).ShowAsync();
                    return(null);
                }
            });

            try
            {
                // Create the utility network.
                _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServerUrl));

                // Create the map.
                MyMapView.Map = new Map(Basemap.CreateTopographicVector());

                // Get all of the edges and junctions in the network.
                IEnumerable <UtilityNetworkSource> edges     = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Edge);
                IEnumerable <UtilityNetworkSource> junctions = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Junction);

                // Add all edges that are not subnet lines to the map.
                foreach (UtilityNetworkSource source in edges)
                {
                    if (source.SourceUsageType != UtilityNetworkSourceUsageType.SubnetLine && source.FeatureTable != null)
                    {
                        MyMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable));
                    }
                }

                // Add all junctions to the map.
                foreach (UtilityNetworkSource source in junctions)
                {
                    if (source.FeatureTable != null)
                    {
                        MyMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable));
                    }
                }

                // Create a graphics overlay for associations.
                _associationsOverlay = new GraphicsOverlay();
                MyMapView.GraphicsOverlays.Add(_associationsOverlay);

                // Symbols for the associations.
                Symbol attachmentSymbol   = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Green, 5d);
                Symbol connectivitySymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Red, 5d);

                // Create a renderer for the associations.
                var attachmentValue   = new UniqueValue("Attachment", string.Empty, attachmentSymbol, UtilityAssociationType.Attachment.ToString());
                var connectivityValue = new UniqueValue("Connectivity", string.Empty, connectivitySymbol, UtilityAssociationType.Connectivity.ToString());
                _associationsOverlay.Renderer = new UniqueValueRenderer(new List <string> {
                    "AssociationType"
                }, new List <UniqueValue> {
                    attachmentValue, connectivityValue
                }, string.Empty, null);

                // Populate the legend in the UI.
                Dictionary <UtilityAssociationType, ImageSource> legend;
                legend = new Dictionary <UtilityAssociationType, ImageSource>();

                RuntimeImage attachmentSwatch = await attachmentSymbol.CreateSwatchAsync();

                legend[UtilityAssociationType.Attachment] = await attachmentSwatch?.ToImageSourceAsync();

                RuntimeImage connectSwatch = await connectivitySymbol.CreateSwatchAsync();

                legend[UtilityAssociationType.Connectivity] = await connectSwatch?.ToImageSourceAsync();

                AssociationLegend.ItemsSource = legend;

                // Set the starting viewpoint.
                await MyMapView.SetViewpointAsync(InitialViewpoint);

                // Add the associations in the starting viewpoint.
                AddAssociations();
            }
            catch (Exception ex)
            {
                await new MessageDialog2(ex.Message, ex.GetType().Name).ShowAsync();
            }
        }
Beispiel #8
0
        public Basemap GetBasemap(BasemapType basemapType)
        {
            Basemap basemap = null;

            switch (basemapType)
            {
            case BasemapType.Imagery:
                basemap = Basemap.CreateImagery();
                break;

            case BasemapType.ImageryWithLabels:
                basemap = Basemap.CreateImageryWithLabels();
                break;

            case BasemapType.Streets:
                basemap = Basemap.CreateStreets();
                break;

            case BasemapType.Topographic:
                basemap = Basemap.CreateTopographic();
                break;

            case BasemapType.TerrainWithLabels:
                basemap = Basemap.CreateTerrainWithLabels();
                break;

            case BasemapType.LightGrayCanvas:
                basemap = Basemap.CreateLightGrayCanvas();
                break;

            case BasemapType.NationalGeographic:
                basemap = Basemap.CreateNationalGeographic();
                break;

            case BasemapType.Oceans:
                basemap = Basemap.CreateOceans();
                break;

            case BasemapType.OpenStreetMap:
                basemap = Basemap.CreateOpenStreetMap();
                break;

            case BasemapType.ImageryWithLabelsVector:
                basemap = Basemap.CreateImageryWithLabelsVector();
                break;

            case BasemapType.StreetsVector:
                basemap = Basemap.CreateStreetsVector();
                break;

            case BasemapType.TopographicVector:
                basemap = Basemap.CreateTopographicVector();
                break;

            case BasemapType.TerrainWithLabelsVector:
                basemap = Basemap.CreateTerrainWithLabelsVector();
                break;

            case BasemapType.LightGrayCanvasVector:
                basemap = Basemap.CreateLightGrayCanvasVector();
                break;

            case BasemapType.NavigationVector:
                basemap = Basemap.CreateNavigationVector();
                break;

            case BasemapType.StreetsNightVector:
                basemap = Basemap.CreateStreetsVector();
                break;

            case BasemapType.StreetsWithReliefVector:
                basemap = Basemap.CreateStreetsWithReliefVector();
                break;

            case BasemapType.DarkGrayCanvasVector:
                basemap = Basemap.CreateDarkGrayCanvasVector();
                break;

            default:
                break;
            }

            return(basemap);
        }
Beispiel #9
0
        public Basemap GetBaseMap(CusMapView cusMapView)
        {
            switch (cusMapView.Map.MapType)
            {
            case MapType.Imagery:
                return(Basemap.CreateImagery());

            case MapType.Streets:
                return(Basemap.CreateStreets());

            case MapType.ImageryWithLabels:
                return(Basemap.CreateImageryWithLabels());

            case MapType.ImageryWithLabelsVector:
                return(Basemap.CreateImageryWithLabelsVector());

            case MapType.LightGrayCanvas:
                return(Basemap.CreateLightGrayCanvas());

            case MapType.LightGrayCanvasVector:
                return(Basemap.CreateLightGrayCanvasVector());

            case MapType.DarkGrayCanvasVector:
                return(Basemap.CreateDarkGrayCanvasVector());

            case MapType.NationalGeographic:
                return(Basemap.CreateNationalGeographic());

            case MapType.Oceans:
                return(Basemap.CreateOceans());

            case MapType.StreetsVector:
                return(Basemap.CreateStreetsVector());

            case MapType.StreetsWithReliefVector:
                return(Basemap.CreateStreetsWithReliefVector());

            case MapType.StreetsNightVector:
                return(Basemap.CreateStreetsNightVector());

            case MapType.NavigationVector:
                return(Basemap.CreateNavigationVector());

            case MapType.TerrainWithLabels:
                return(Basemap.CreateTerrainWithLabels());

            case MapType.TerrainWithLabelsVector:
                return(Basemap.CreateTerrainWithLabelsVector());

            case MapType.Topographic:
                return(Basemap.CreateTopographic());

            case MapType.TopographicVector:
                return(Basemap.CreateTopographicVector());

            case MapType.OpenStreetMap:
                return(Basemap.CreateOpenStreetMap());

            case MapType.WebMap:
                if (!string.IsNullOrEmpty(cusMapView.Map.WebMapUrl))
                {
                    return(new Basemap(new Uri(cusMapView.Map.WebMapUrl)));
                }

                throw new ArgumentOutOfRangeException(nameof(cusMapView.Map.WebMapUrl), cusMapView.Map.WebMapUrl, null);

            default:
                throw new ArgumentOutOfRangeException(nameof(cusMapView.Map.MapType), cusMapView.Map.MapType, null);
            }
        }
        private async void Initialize()
        {
            try
            {
                // Create the utility network.
                _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServerUrl));

                // Create the map.
                MyMapView.Map = new Map(Basemap.CreateTopographicVector());

                // Get all of the edges and junctions in the network.
                IEnumerable <UtilityNetworkSource> edges     = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Edge);
                IEnumerable <UtilityNetworkSource> junctions = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Junction);

                // Add all edges that are not subnet lines to the map.
                foreach (UtilityNetworkSource source in edges)
                {
                    if (source.SourceUsageType != UtilityNetworkSourceUsageType.SubnetLine && source.FeatureTable != null)
                    {
                        MyMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable));
                    }
                }

                // Add all junctions to the map.
                foreach (UtilityNetworkSource source in junctions)
                {
                    if (source.FeatureTable != null)
                    {
                        MyMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable));
                    }
                }

                // Create a graphics overlay for associations.
                _associationsOverlay = new GraphicsOverlay();
                MyMapView.GraphicsOverlays.Add(_associationsOverlay);

                // Symbols for the associations.
                Symbol attachmentSymbol   = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Green, 5d);
                Symbol connectivitySymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Red, 5d);

                // Create a renderer for the associations.
                var attachmentValue   = new UniqueValue("Attachment", string.Empty, attachmentSymbol, UtilityAssociationType.Attachment.ToString());
                var connectivityValue = new UniqueValue("Connectivity", string.Empty, connectivitySymbol, UtilityAssociationType.Connectivity.ToString());
                _associationsOverlay.Renderer = new UniqueValueRenderer(new List <string> {
                    "AssociationType"
                }, new List <UniqueValue> {
                    attachmentValue, connectivityValue
                }, string.Empty, null);

                // Populate the legend in the UI.
                Dictionary <UtilityAssociationType, System.Windows.Media.ImageSource> legend;
                legend = new Dictionary <UtilityAssociationType, System.Windows.Media.ImageSource>();

                RuntimeImage attachmentSwatch = await attachmentSymbol.CreateSwatchAsync();

                legend[UtilityAssociationType.Attachment] = await attachmentSwatch?.ToImageSourceAsync();

                RuntimeImage connectSwatch = await connectivitySymbol.CreateSwatchAsync();

                legend[UtilityAssociationType.Connectivity] = await connectSwatch?.ToImageSourceAsync();

                AssociationLegend.ItemsSource = legend;

                // Set the starting viewpoint.
                await MyMapView.SetViewpointAsync(InitialViewpoint);

                // Add the associations in the starting viewpoint.
                AddAssociations();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public async void ChangeBasemap(string basemap)
        {
            // Apply the selected basemap to the map
            switch (basemap)
            {
            case "Topographic":
                // Set the basemap to Topographic
                _map.Basemap = Basemap.CreateTopographic();
                break;

            case "Topographic Vector":
                // Set the basemap to Topographic (vector)
                _map.Basemap = Basemap.CreateTopographicVector();
                break;

            case "Streets":
                // Set the basemap to Streets
                _map.Basemap = Basemap.CreateStreets();
                break;

            case "Streets Vector":
                // Set the basemap to Streets (vector)
                _map.Basemap = Basemap.CreateStreetsVector();
                break;

            case "Imagery":
                // Set the basemap to Imagery
                _map.Basemap = Basemap.CreateImagery();
                break;

            case "Oceans":
                // Set the basemap to Oceans
                _map.Basemap = Basemap.CreateOceans();
                break;

            case "USGS National Map":
                // Set the basemap to USGS National Map by opening it from ArcGIS Online
                var itemID = "809d37b42ca340a48def914df43e2c31";

                // Connect to ArcGIS Online
                ArcGISPortal agsOnline = await ArcGISPortal.CreateAsync();

                // Get the USGS webmap item
                PortalItem usgsMapItem = await PortalItem.CreateAsync(agsOnline, itemID);

                // Create a new basemap using the item
                _map.Basemap = new Basemap(usgsMapItem);
                break;

            case "World Globe 1812":
                // Create a URI that points to a map service to use in the basemap
                var uri = new Uri("https://tiles.arcgis.com/tiles/IEuSomXfi6iB7a25/arcgis/rest/services/World_Globe_1812/MapServer");

                // Create an ArcGISTiledLayer from the URI
                ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(uri);

                // Create a basemap from the layer and assign it to the map
                _map.Basemap = new Basemap(baseLayer);
                break;
            }
        }