Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <html>

<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
	<title>ArcGIS JSAPI Calcite</title>
	<link rel="stylesheet" type="text/css" href="https://unpkg.com/@esri/calcite-components@1.0.0-beta.75/dist/calcite/calcite.css" />
	<link rel="stylesheet" href="https://js.arcgis.com/next/esri/themes/light/main.css" />
	<script src="https://js.arcgis.com/calcite-components/1.0.0-beta.74/calcite.esm.js" type="module"></script>
</head>

<body>
	<main>
		<div class="container">
			<calcite-card>
				<div id="featureTarget"></div>
				<calcite-button slot="footer-leading" color="neutral" scale="s" icon-start="magnifying-glass-plus" id="btnZoom"></calcite-button>
				<div slot="footer-trailing">
					<span id="infoCount" class="ui-info--count">
					</span>
					<calcite-button id="btnPrevious" color="neutral" icon-start="chevron-left"></calcite-button>
					<calcite-button id="btnNext" color="neutral" icon-start="chevron-right"></calcite-button>
				</div>
			</calcite-card>
		</div>
		<div id="viewDiv"></div>
	</main>

</body>

</html>
              
            
!

CSS

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

#viewDiv {
	width: 100%;
}

main {
	display: flex;
	height: 100%;
}

.container {
	width: 400px;
	height: 100vh;
	overflow-y: auto;
}

.ui-info--count {
    margin-left: 1rem;
    margin-right: 1rem;
}
              
            
!

JS

              
                import ArcGISMap from "https://js.arcgis.com/next/@arcgis/core/Map.js";
import MapView from "https://js.arcgis.com/next/@arcgis/core/views/MapView.js";
import FeatureLayer from "https://js.arcgis.com/next/@arcgis/core/layers/FeatureLayer.js";
import { whenFalseOnce } from "https://js.arcgis.com/next/@arcgis/core/core/watchUtils.js";
import Feature from "https://js.arcgis.com/next/@arcgis/core/widgets/Feature.js";

const fLayer = new FeatureLayer({
	portalItem: {
		id: "f430d25bf03744edbb1579e18c4bf6b8"
	},
	layerId: 2,
	outFields: ["*"]
});

const map = new ArcGISMap({
	basemap: "gray-vector",
	layers: [fLayer]
});

const view = new MapView({
	container: "viewDiv",
	map,
	center: [-118, 34],
	zoom: 12
});

const featureTarget = document.getElementById("featureTarget");
const btnZoom = document.getElementById("btnZoom");
const previous = document.getElementById("btnPrevious");
const next = document.getElementById("btnNext");
const info = document.getElementById("infoCount");

const feature = new Feature({
	view,
	container: featureTarget
});

view.when(async () => {
	// do stuff here
	let highlight;
	let currIndex = 0;
	let totalCount = 1;
	const layerView = await view.whenLayerView(fLayer);
	await whenFalseOnce(view, "updating");
	const query = fLayer.createQuery();
	query.geometry = view.extent;
	const { features } = await layerView.queryFeatures(query);
	
	const update = () => {
		if (currIndex < 0) {
			currIndex = features.length - 1;
		}
		else if (currIndex === features.length) {
			currIndex = 0;
		}
		
		feature.graphic = features[currIndex];
		info.innerText = `${currIndex + 1} of ${features.length}`;
		
		// highlight
		highlight && highlight.remove();
		highlight = layerView.highlight(feature.graphic);
	};
	
	btnPrevious.addEventListener("click", () => {
		currIndex = currIndex - 1;
		update();
	});
	btnNext.addEventListener("click", () => {
		currIndex = currIndex + 1;
		update();
	});
	
	btnZoom.addEventListener("click", () => {
		view.goTo({
			target: feature.graphic
		});
	});
	
	update();
	
});


              
            
!
999px

Console