Home > Software engineering >  Web map showing default basemap instead of defined map using arcgis sdk
Web map showing default basemap instead of defined map using arcgis sdk

Time:10-22

I am trying to make a web map.

So, that applications and APIs can read, write, and display web maps.

The following code I modify in .net, but when I run this code, it is giving error.

I go through a number of tutorials on this issue, but still not able to find find a confident solution.

Below is the my way of achieving the web map.

private void SetupMap()
        {

            // Create a new map with a 'topographic vector' basemap.
            Map = new Map(BasemapStyle.ArcGISTopographic);

        }
private async Task SetupMap()
        {

            // Create a portal. If a URI is not specified, www.arcgis.com is used by default.
            ArcGISPortal portal = await ArcGISPortal.CreateAsync();

            // Get the portal item for a web map using its unique item id.
            PortalItem mapItem = await PortalItem.CreateAsync(portal, "41281c51f9de45edaf1c8ed44bb10e30");

            // Create the map from the item.
            Map map = new Map(mapItem);

            // To display the map, set the MapViewModel.Map property, which is bound to the map view.
            this.Map = map;

        }

Any help or workaround.

CodePudding user response:

In the MapViewModel class, remove all the existing code in the SetupMap() function.

private void SetupMap()
        {

            // Create a new map with a 'topographic vector' basemap.
            Map = new Map(BasemapStyle.ArcGISTopographic);

        }

Save your code and Click Debug > Start Debugging (or press on the keyboard) to run the app.

  • Related