Select to view content in your preferred language

Basemap Gallery component - Add basemap from tile layer

220
4
Jump to solution
a week ago
MatthewDriscoll
MVP Alum

Does anyone have an example of how to remove the default basemaps in the basemap gallery component and add our own from a service layer.  I am struggling.  Thanks.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
AnneFitz
Esri Regular Contributor

Hi @MatthewDriscoll - yes you can use the Basemap Gallery component to do this! Just set the source via JavaScript after adding the component to your markup. Example code snippet here - https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-basemap-gallery/#so...

View solution in original post

0 Kudos
4 Replies
Laura
by MVP Regular Contributor
MVP Regular Contributor
0 Kudos
MatthewDriscoll
MVP Alum

No, not through online.  Using the SDK code.  Add the component in HTML and put it in a slot, then customize it in JS.  This the way the new format is supposed to go, no? 

    <!--Basemap Gallery-->
    <arcgis-basemap-gallery
        id="baseMapGal"
        slot="top-right">
    </arcgis-basemap-gallery>
const basemapGallery = document.getElementById("baseMapGal");

 

0 Kudos
MatthewDriscoll
MVP Alum

I think I may have gotten it, or at least a working solution, by using the LocalBasemapsSources?  However the format/look is different.  So I am not sure.  Would still like to know if the actual basemap gallery component is a direction I can take. 

let basemapGallery = new BasemapGallery({
 source: new LocalBasemapsSource({
   basemaps: [
     myBasemap//Basemap.fromId("topo-vector"), // create a basemap from a well known id basemap
   ]
  }),
 view: view
});
view.ui.add(basemapGallery, 'top-right');


 

0 Kudos
AnneFitz
Esri Regular Contributor

Hi @MatthewDriscoll - yes you can use the Basemap Gallery component to do this! Just set the source via JavaScript after adding the component to your markup. Example code snippet here - https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-basemap-gallery/#so...

0 Kudos