Search code examples
javascriptesriarcgis-js-api

Is it possible to specify which ArcGIS base-maps to use for the ESRI basemap gallery (ArcGIS API)?


Is it possible to specify which ArcGIS base-maps to use for the ESRI base-map gallery (esri/dijit/BasemapGallery)?

Setting showArcGISBasemaps to true brings back all of them but I only want a select few e.g. "road", "national-geographic" and "satellite".

var basemapGallery = new BasemapGallery({
    showArcGISBasemaps: true,
    map: map,
}, "myPlaceHolder");

Looking through the documentation (https://developers.arcgis.com/javascript/3/jsapi/basemapgallery-amd.html) I can't seem to find anything.

Alternatively, is it possible to create these layers individually after setting showArcGISBasemaps to false?


Solution

  • Turns out I had to locate the layers manually after finding them on the ArcGIS services: http://server.arcgisonline.com/ArcGIS/rest/service

    var greyLayer = new esri.dijit.BasemapLayer({
        url: "http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer"
    });
    
    var greyBasemap = new esri.dijit.Basemap({
        url: [greyLayer],
        id: "mybaselayerId",
        title: "Grey"
    });
    
    basemaps.push(greyBasemap);
    
    var basemapGallery = new BasemapGallery({
        showArcGISBasemaps: false,
        basemaps: basemaps,
        map: map,
    }, "myPlaceHolder");
    

    There doesn't seem to be an option to filter the basemaps returned from showArcGISBasemaps