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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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">
  <title>ArcGIS Globe</title>
  <link rel="stylesheet" href="https://js.arcgis.com/4.8/esri/css/main.css">
  <script src="https://js.arcgis.com/4.8/"></script>
</head>

<body>
  <header>
    <div id="circle"></div>
    <div id="floating-text">
      <h2>World's Largest Cities</h2>
      
      <p>This globe highlights the cities in the world with the largest populations. Every city with a population over 5 million are labeled. The white points represent cities that have a population greater than 500 thousand. </p>
        <p>
        Clicking on the labeled cities will open pop-ups that reveal the city's population. This application was created using ArcGIS's Javascript API.
    </div>
  </header>
  
  <div id="view"></div>
  
 
  
</body>
  
</html>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Open+Sans');

html, body {
  padding: 0;
  margin: 0;
  height: 100%;
  width: 100%;
background: #005AA7;  /* fallback for old browsers */
background: -webkit-linear-gradient(150deg,#005AA7, #FFFDE4);  /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(150deg, #005AA7, #FFFDE4); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
 

#circle {
  height: 100%;
  width: 100%;
  shape-outside: circle(30%);
  float: right;
}

#view {
  height: 100%;
  width: 100%;
}

#view canvas{
  filter: drop-shadow(26px 15px 5px rgba(0,0,0, 0.5));
}

header {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 100%;
}

#floating-text {
  font-size: 1.1em;
  text-align: left;
  padding: 20px;
  font-family: 'Open Sans', sans-serif;
  color: #ffffff;
}

span {
  font-weight: bold;
}

.esri-component.esri-attribution.esri-widget {
  background-color: transparent;
}

              
            
!

JS

              
                 
//all of the functions need to be called out in the require section:
require([
        "esri/WebScene",
        "esri/views/SceneView",
        "esri/layers/FeatureLayer",
        "esri/layers/support/LabelClass"
      ], function(WebScene, SceneView, FeatureLayer, LabelClass) {
   
  ///I am using a webscene here, and I am calling it 'map', no basemap, and the surface color is the ball's color (ocean)
        var map = new WebScene({
          basemap: null,
          ground: {
            surfaceColor: '#004C73'
          }
        });
  
///Creating the SceneView, I have changed the 'environment' to remove the stars, the atmopohere, and the lighting. I get rid of the background as well
        var view = new SceneView({
          container: "view",
          map: map,
          alphaCompositingEnabled: true,
          center: [90.168214, 18.808395],
          scale: 50000000000,
          constraints: {
            altitude: {
                 min: 19000000,
                 max: 26000000
            }
              },
          environment: {
            starsEnabled: false,
            atmosphereEnabled: false,
            lighting: {
  date: "Sun Jul 15 2018 15:30:00 GMT+0900 (W. Europe Daylight Time)"
},
            background: {
              type: "color",
              color: [0, 0, 0, 0]
               },
              
          }
        });

  ///get rid of UI
   view.ui.empty("top-left");
  
  ///add a feature service, these are country boundaries, creating my own basemap
   var countryBoundaries = new FeatureLayer({
          url: "http://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Countries_(Generalized)/FeatureServer",
          title: "World Countries",
  // we use a simple renderer when we want to symbolize all features with the same symbol, how the feature service will look
           renderer: {
           type: "simple",
           symbol: {
            type: "polygon-3d",
            symbolLayers: [{
            type: "fill",
        material: { color: [255, 255, 213, 0.5] },
        outline: {
          color: [0,0,0, 1]
        }
      }]
    }
  }
});
 
 ////Creaitng a popup template, forcing popup to only show title, forcing popup to close when map is moved or clicked off of popup
    var popup = {
          title: "{CITY_NAME}, {CNTRY_NAME} has a Population of {POP}",
      }
    view.popup.collapsed = true; 
    view.popup.autoCloseEnabled = true;
  
 ////First Population layer that will be used for labeling, uses callouts and vertical offsets to make a 3D effect
   var populationLayer = new FeatureLayer({
     url: "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Cities_analysis/FeatureServer",
      definitionExpression: "POP > 5000000",
     outFields: ["CITY_NAME","CNTRY_NAME","POP"],
     popupTemplate: popup,
     renderer: {
      type: "simple",
      symbol: {
      type: "point-3d",
      symbolLayers: [{
       type: "icon",
      size: 9,
      resource: { primitive: "circle" },
      material: { color: "#000040" },
      outline: {
        size: 1,
        color: "white"
      }
    }],
    verticalOffset: {
      screenLength: 25
    },
    callout: {
      type: "line", // autocasts as new LineCallout3D()
      size: 2.5,
      color: "#1846ed"
    }
  }
     }
});
 
////add a label to the above layer, using the label expression
   populationLayer.labelingInfo = [
  new LabelClass({
    labelExpressionInfo: { expression: "$feature.CITY_NAME" },
    symbol: {
      type: "label-3d",
      symbolLayers: [{
        type: "text",
        material: { color: "white" },
        size: 11,
        font: {
          family: "Open Sans",
          weight: "bold"
        },
        halo: {
          color: "black",
          size: 1
        }
      }]
    }
  })
     
];

////adding grid lines to the globe for clarity
   var graticule = new FeatureLayer({
  url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/World_graticule_15deg/FeatureServer",
  opacity: 0.4
});

////other cities layer, shows all cities within the definition expression. visualized as white
   var citieslayer = new FeatureLayer({
  url: "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Cities_analysis/FeatureServer",
   definitionExpression: "POP > 500000",
     renderer: {
      type: "simple",
      symbol: {
      type: "point-3d",
      symbolLayers: [{
       type: "icon",
      size: 5,
      resource: { primitive: "circle" },
      material: { color: [255,255,255, 0.7] },
    }]
  }
     }
});
   

// addmany will add all the layers created above to the globe
map.addMany([graticule, countryBoundaries, populationLayer, citieslayer]);
   
});
              
            
!
999px

Console