Detect loaded maps in MapView

1760
3
Jump to solution
02-11-2021 01:01 PM
GregoryBologna
Occasional Contributor II

I am loading two maps in a view. One map is the basemap "streets", and the other is from a 3rd party provider that is infrequently unavailable. How can I know if the "streets" basemap is the only map loaded in the view?

Example

const map = new Map({
   basemap: "streets"
});

const anothermap = new GroupLayer({
   title: "Aerials",
   visible: true,
   visibilityMode: "exclusive",
   layers: tileServers
});
map.add(anothermap);

I only want to know if "anothermap" did not get loaded.
 
 I found this post by Robert S. but baseLayerViews is always 0.
  

var view = new MapView({
map: map,
[...]

view.when(function () {

//  this is always 0 and it blows up
//  view.basemapView.baseLayerViews.getItemAt(0)

    watchUtils.whenFalse(view.basemapView.baseLayerViews.getItemAt(0), 'updating', (updating) => {
      if(view.stationary){
        console.log('Done Updating');
      } else {
        watchUtils.whenTrueOnce(view, "stationary", (still) => {
          console.log('Done Updating');
        });
      }
    });

 [...]

 

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
3 Replies
KenBuja
MVP Esteemed Contributor

This blog post shows how you can tell when a layer is loaded and ready: https://odoe.net/blog/when-are-layers-done

GregoryBologna
Occasional Contributor II

I want to know if the basemap is the only map in the view when the entire view is done. 

- basemap--------Loaded
- anothermap----Not loaded
-- layers

0 Kudos
GregoryBologna
Occasional Contributor II
0 Kudos