BasemapGallery - how to limit list?

1215
4
09-14-2018 06:16 AM
Shane_
by
New Contributor II

Using the JavaScript API 4.8, how can I create a basemap gallery with just the Imagery and Streets basemaps?

This is what I'm using to create the basemapGallery: 

basemapGallery = new BasemapGallery({ view: view, container: document.createElement("div") });

Thanks,

Shane

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Shane,

  See this thread where I show a sample on how to remove certain basemaps.

https://community.esri.com/thread/217248-how-do-i-remove-basemaps-from-the-default-47-basemapgallery 

0 Kudos
Shane_
by
New Contributor II

Thanks Robert.

I tried to use basemapGallery.source.basemaps.removeAt(2);

directly after I have created the basemapGallery i.e. on the line following

basemapGallery = new BasemapGallery({ view: view, container: document.createElement("div") });

but it doesn't work. Any suggestions?

Thanks,

Shane

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Shane that is why in my sample code I do not try to remove it right after I create the list.

      watchUtils.once(basemapGallery.source.basemaps,"length", function(state){
        setTimeout(function(){
          basemapGallery.source.basemaps.removeAt(2);
        }, 200);
      });
0 Kudos
Juan_CarlosFranco
Esri Contributor

You can use `PortalBasemapsSource#filterFunction` for this purpose. Here's an example: [BasemapGallery] Filter basemaps