Pen Settings



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


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.


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.


                <!DOCTYPE HTML>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"
  <title>ArcGIS JS API Tutorials: Access traffic using OAuth2</title>
    <script src=""></script>
    body, #viewDiv{
      font-family: Avenir Next W00;
      font-size: 14px;
      width: 100%;
      height: 100%;
      margin: 0px;
      padding: 0px;

    .action {
      color: blue;
      cursor: pointer;
      text-decoration: underline;

    ], function(
        Portal, OAuthInfo, identityManager, Map, MapView, MapImageLayer,
        domStyle, domAttr, on, dom) {

      // ArcGIS Online or your portal address
      var portalUrl = "";

      function displayMap() {
        var portal = new Portal();

        // Once the portal has loaded, the user is signed in
        portal.load().then(function() {
          dom.byId('viewDiv').style.display = 'flex';

          var map = new Map({
            basemap: "topo"

          var view = new MapView({
            container: "viewDiv",
            map: map,
            zoom: 14,
            center: [-118.24,34.05]

          var traffic = new MapImageLayer({
            url: ''

      // subsitute your own client ID to identify who spawned the login and check for a matching redirect URI
      var info = new OAuthInfo({
        appId: "your client id", //*** Your Client ID value goes here ***//
        popup: false // inline redirects don't require any additional app configuration


      // send users to to login
      on(dom.byId("sign-in"), "click", function() {

      // log out and reload
      on(dom.byId("sign-out"), "click", function() {

      identityManager.checkSignInStatus(portalUrl).then(function() {
       dom.byId('anonymousPanel').style.display = 'none';
       dom.byId('personalizedPanel').style.display = 'block';


  <div id="anonymousPanel" style="display: block; padding: 5px; text-align: center;">
    <span id="sign-in" class="action">Sign In</span> to see live traffic.

  <div id="personalizedPanel" style="display: none; padding: 5px; text-align: center;">
    Welcome <span id="userId" style="font-weight: bold;"></span> &nbsp;-&nbsp;
    <span id="sign-out" class="action">Sign Out</span>
  <!-- for the map -->
  <div id="viewDiv" style="display: none;"></div>