HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<!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>
@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;
}
//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]);
});
Also see: Tab Triggers