<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Basemap worldview | Sample | ArcGIS Maps SDK for JavaScript</title>
apiKey: "YOUR_ACCESS_TOKEN",
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
<script type="module" src="https://js.arcgis.com/5.0/"></script>
<arcgis-map id="map-1" basemap="arcgis/community" center="-90.02961, 26.79342" zoom="4">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<div id="default" slot="top-right">Default Basemap Worldview</div>
<arcgis-map id="map-2" basemap="arcgis/community" center="-90.02961, 26.79342" zoom="4">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<div id="basemapWorldview" slot="top-right">
<calcite-label>Basemap worldview</calcite-label>
placeholder="Select a worldview"
clear-disabled></calcite-combobox>
const [esriRequest, Basemap, BasemapStyle, Extent] = await $arcgis.import([
"@arcgis/core/request.js",
"@arcgis/core/Basemap.js",
"@arcgis/core/support/BasemapStyle.js",
"@arcgis/core/geometry/Extent.js",
const viewElement1 = document.querySelector("#map-1");
const viewElement2 = document.querySelector("#map-2");
viewElement2.basemap = new Basemap({
style: new BasemapStyle({
worldview: "unitedStatesOfAmerica",
// update combobox values with worldviews from rest endpoint
const basemapStylesEndpoint =
"https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/styles/self";
esriRequest(basemapStylesEndpoint, {
const json = response.data;
// add each worldview as a combobox item
json.worldviews.forEach((worldview) => {
const comboboxItem = document.createElement("calcite-combobox-item");
comboboxItem.value = worldview.code;
comboboxItem.heading = worldview.name;
comboboxItem.selected = viewElement2.basemap.style.worldview === worldview.code;
worldviewCombobox.appendChild(comboboxItem);
// set extents for each of the worldview locations
const worldviewLocations = {
xmax: 123.62885668387374,
xmax: 105.76656873549308,
ymin: 29.767839683872268,
ymax: 46.090722101828995,
xmin: -23.347082138056592,
ymin: 18.808998642260764,
xmin: 121.22558538612685,
xmax: 134.38720647987336,
ymax: 40.463848969139285,
unitedArabEmirates: new Extent({
ymin: 21.546327085249732,
unitedStatesOfAmerica: new Extent({
xmin: -103.08145244811661,
ymin: 15.496689338094148,
xmax: -76.75821026062363,
xmax: 119.05929740722358,
ymax: 24.812143623220667,
const updateWorldview = (worldviewCode) => {
// update the basemap worldview
viewElement2.basemap = new Basemap({
style: new BasemapStyle({
worldview: worldviewCode,
// go to the extent that matches the current worldview
viewElement1.goTo(worldviewLocations[worldviewCode]);
viewElement2.extent = worldviewLocations[worldviewCode];
const worldviewCombobox = document.getElementById("worldviewCombobox");
// when the combobox value changes, update the worldview
worldviewCombobox.addEventListener("calciteComboboxChange", () => {
updateWorldview(worldviewCombobox.value);