Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Save Automatically?

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.

HTML

              
                <!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
  <title>Intro to popups | Sample | ArcGIS API for JavaScript 4.16</title>

  <link rel="stylesheet" href="https://js.arcgis.com/4.16/esri/themes/light/main.css" />
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css">
  <script src="https://js.arcgis.com/4.16/"></script>
  <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js"></script>

</head>

<body>
  <div id="viewDiv"></div>
  <div id="instruction" class="esri-widget">
    Click any location on the map to see its street address
  </div>
</body>

</html>
              
            
!

CSS

              
                html,
body,
#viewDiv {
  padding: 0;
  margin: 0;
  height: 100%;
  width: 100%;
}

#instruction {
  z-index: 99;
  position: absolute;
  top: 15px;
  left: 50%;
  padding: 5px;
  margin-left: -175px;
  height: 30px;
  width: 355px;
  background: rgba(25, 25, 25, 0.8);
  color: white;
}
              
            
!

JS

              
                require(["esri/tasks/Locator", "esri/Map", "esri/views/MapView"], function (
  Locator,
  Map,
  MapView
) {
  // Set up a locator task using the world geocoding service
  var locatorTask = new Locator({
    url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"
  });
  // Create the Map
  var map = new Map({
    basemap: "streets-navigation-vector"
  });
  // Create the MapView
  var view = new MapView({
    container: "viewDiv",
    map: map,
    center: [-71.6899, 43.7598],
    zoom: 12
  });

  // Renders when the popup template content is updated
  view.popup.watch(
    [
      "content.viewModel.content",
      "dockEnabled",
      "selectedFeature",
      "selectedFeatureIndex",
      "collapsed",
      "visible"
    ],
    (newValue, oldValue, propertyName, target) => {
      // console.log(newValue, oldValue, propertyName, target);
      setTimeout(() => {
        // Initialize the Semantic UI Tabs
        $(".esri-popup__content").find(".menu .item").tab();
      }, 500);
    }
  );

  /*******************************************************************
   * This click event sets generic content on the popup not tied to
   * a layer, graphic, or popupTemplate. The location of the point is
   * used as input to a reverse geocode method and the resulting
   * address is printed to the popup content.
   *******************************************************************/
  view.popup.autoOpenEnabled = false;
  view.on("click", function (event) {
    // Get the coordinates of the click on the view
    var lat = Math.round(event.mapPoint.latitude * 1000) / 1000;
    var lon = Math.round(event.mapPoint.longitude * 1000) / 1000;
    view.popup.open({
      // Set the popup's title to the coordinates of the location
      title: "Reverse geocode: [" + lon + ", " + lat + "]",
      location: event.mapPoint // Set the location of the popup to the clicked location
    });
    var params = {
      location: event.mapPoint
    };
    // Display the popup
    // Execute a reverse geocode using the clicked location
    locatorTask
      .locationToAddress(params)
      .then(function (response) {
        // If an address is successfully found, show it in the popup's content
        view.popup.content = `
          <div class="ui fluid two item secondary pointing menu">
            <a class="active item" data-tab="tab_a">Tab A</a>
            <a class="item" data-tab="tab_b">Tab B</a>
          </div>

          <div class="ui active tab" data-tab="tab_a">Tab A</div>
          <div class="ui tab" data-tab="tab_b">Tab B</div>
        `;
      })
      .catch(function (error) {
        // If the promise fails and no result is found, show a generic message
        view.popup.content = "something went wrong";
      });
  });
});

              
            
!
999px

Console