Switching Basemaps via code

248
0
11-23-2022 01:45 AM
FabioPizzella
New Contributor

Hello,

I'm trying to switch to this basemap at runtime. I'm trying to assign the URL to the ArcGISMapComponent instance, like: 

 

ArcGISMapComponent _arcGISMap = GetComponent<ArcGISMapComponent>();
_arcGISMap.Basemap = "https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_GCS_v2/VectorTileServer";

 

  but I get this error: 

 

ArcGISViewState changed to : NoViewport, Error (Invalid argument.)
Additional info: tile info origin must have a spatial reference.

 

 

I'm also trying a different approach, by creating a ArcGISBaseMap and assigning it to the ArcGISMapComponent View.Map.Basemap, like:

 

var map = new ArcGISBasemap("https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_GCS_v2/VectorTileServer", "myApiKey");
_arcGISMap.View.Map.Basemap = map;
_arcGISMap.View.Map.Basemap.Load();
_arcGISMap.View.Map.DoneLoading += OnDoneLoading;
.....

private void OnDoneLoading(Exception loadError)
{
    if (loadError != null)
        Debug.LogError(loadError.Message);
    else
    ... 
}

 

but loadError returns this:

 

User canceled.: Load was canceled by user.

 

 

Any ideas?

 

Tags (3)
0 Kudos
0 Replies