Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <link rel="stylesheet" href="" />
<div id="viewDiv"></div>


#viewDiv {
  padding: 0;
  margin: 0;
  height: 100%;
  width: 100%;

.esri-view-root .esri-ui .esri-attribution {
  left: auto;



                import MapView from "";
import Basemap from "";
import BasemapGallery from "";
import Expand from "";
import Portal from "";
import PortalItem from "";
import PortalGroup from "";
import PortalQueryParams from "";

// Gets all the portal Item IDs from the group
const getPortalItemIds = async () => {
  const g = new PortalGroup({
    id: "4c790318395940c18a16e8acd721de25",
    portal: new Portal()

  const portalQueryResult = await g.queryItems(
    new PortalQueryParams({
      num: 100

  const results = portalQueryResult.results;

  // only work on vector tiles for now
  const webMapResults = results.filter((x) => x.type === "Web Map");
  const ids = =>;
  return ids;

const basemapItemIds = await getPortalItemIds();

// Create Basemap instances from all the IDs that we just got.
const basemaps = => {
  return new Basemap({
    portalItem: {
      id: x

// Create the map and the mapview. Use one of the basemaps
// from above as the initial basemap.
const viewOptions = {
  container: "viewDiv",
  map: {
    basemap: basemaps[5]
  center: [-98.35, 39.5],
  zoom: 3
const view = new MapView(viewOptions);

view.when(() => {
  // After the map view loads, create the Basemap Gallery widget-
  // pass the Basemaps from the WGS84 group we created at the beginning.
  let basemapGallery = new BasemapGallery({
    view: view,
    source: basemaps

  // Place the Basemap Gallery widget within the Expand widget.
  const expand = new Expand({
    view: view,
    content: basemapGallery,
    expandTooltip: "Change Basemap"
  view.ui.add(expand, "top-right");

  // When a basemap is selected, hide the expand widge
  // ("Auto-close" the menu)"activeBasemap", function () {
    expand.expanded = !expand.expanded;