Skip To ContentArcGIS for DevelopersSign In Dashboard
Loading...

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

You can create Basemaps in your ArcGIS API for JavaScript applications using a Portal. In doing so, you can leverage your organizations default basemap or default vector basemap. You can define the portalUrl in the esriConfig and the BasemapGallery widget will use the configured basemaps in that portal.

1. Initialize a Portal Instance

// Default is portal for arcgis.com
var portal = new Portal();

2. Load Portal Resources

// If you define the Portal URL in esriConfig, the
// BasemapGallery widget can determine which basemaps
// to use.
esriConfig.portalUrl = "https://jsapi.maps.arcgis.com";
// Intialize a portal instance and load it
var portal = new Portal();
portal
  .load()
  .then(function() {
    // A portal can be configured to use Vector Basemaps
    // by default or not.
    var basemap = portal.useVectorBasemaps ?
          portal.defaultVectorBasemap : portal.defaultBasemap;
    var map = new Map({
      basemap: basemap
    });
    var view = new MapView({
      container: "viewDiv",
      map: map,
      center: [-118.24, 34.073],
      scale: 10000
    });
    // The BasemapGallery will use the basemaps
    // configured by the Portal URL defined in esriConfig.portalUrl
    var basemapGallery = new BasemapGallery({
      view: view
    });
    var bgExpand = new Expand({
      view: view,
      content: basemapGallery
    });
    view.ui.add(bgExpand, "top-right");
  })
  .catch(function(error) {
    console.warn(error);
  });
});

This allows you to use your organization settings to create consistent applications across your organization.

Sample search results

TitleSample
Loading...