Prior to 100.14 the creation of a Map object with an AGOL basemap was done like this:
new Map(Basemap.CreateStreetsVector())
Starting with 100.14 the recommended new syntax for creating the same is now this:
new Map(new Basemap(BasemapStyle.ArcGISStreets))
The syntax changes is fine. But there is a behavior change also that impacts the integrity of the map structure.
Prior to 100.14, immediately after creating the map, you could inspect the new Map object and see that a basemap layer object is present. It isn't necessarily loaded yet...but structurally it is there represented. This allows independent parts of the application to look at the map structure and react accordingly. For example, if you were building a layer list UI you could see the basemap layer is present and represent it.
Starting with 100.14, if you inspect the new Map object the basemap layer you told it to start with just isn't even there. It only shows up when, and IF, the basemap layer loads. This makes it very difficult to build independent parts of an application that can inspect the map structure and build a UI around it accordingly. And if you happen to be offline (temporarily or part of an offline application) then the basemap never does load and show up in the structure.
After discussion with technical support it was explained that:
There are two replies I have to this answer.
If I add a layer to the map, then ask it what layers it has, I expect to see the layer I just added in the list
Adding a layer to a map does work the way you described.
However, the basemap style scenario you are discussing is entirely different.
It seems reasonable to have the basemap layer be there upon inspection even if it's not loaded yet.
No that is not possible. The definition of the basemap style resides in a backing REST webservice and not within the native api itslef. The api needs to determine the contents (layers) of the style asynchronously by consulting the backing service with a valid api key. This happens lazily during the load process. So the basemap needs to be loaded to populate it with the appropriate layers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.