Switch map styles
Change between the standard, satellite and terrain styles.
Code
Replace YOUR_API_KEY with a key from your Gebeta dashboard, save the file as index.html and open it in a browser.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Switch map styles</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500&display=swap" />
<script src="https://tiles.gebeta.app/static/v3/gebeta-maps.umd.js"></script>
<style>
body { margin: 0; font: 13px/1.4 Geist, system-ui, sans-serif; color: #161616; }
#map { position: absolute; inset: 0; }
.panel { position: absolute; top: 12px; left: 12px; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; max-width: calc(100% - 24px); }
button { border: 0; border-radius: 999px; padding: 8px 14px; background: #fff; color: #161616; font: 500 13px Geist, system-ui, sans-serif; cursor: pointer; box-shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 0 0 1px rgb(0 0 0 / 0.1); transition: background-color 150ms cubic-bezier(0.215, 0.61, 0.355, 1); }
button:hover { background: #f4f4f4; }
button[aria-pressed="true"] { background: #191715; color: #faf9f7; }
</style>
</head>
<body>
<div id="map"></div>
<div class="panel">
<button data-style="https://tiles.gebeta.app/styles/standard/style.json" aria-pressed="true">Standard</button>
<button data-style="https://tiles.gebeta.app/styles/raster/raster.json">Satellite</button>
<button data-style="https://tiles.gebeta.app/styles/standard/terrain/terrain.json">Terrain</button>
</div>
<script>
const gebeta = new GebetaMaps({ apiKey: "YOUR_API_KEY" });
const map = gebeta.init({
container: "map",
center: [38.7578, 9.0192],
zoom: 13,
});
const buttons = document.querySelectorAll(".panel button");
buttons.forEach((button) => {
button.addEventListener("click", () => {
map.setStyle(button.dataset.style);
buttons.forEach((other) => other.setAttribute("aria-pressed", String(other === button)));
});
});
</script>
</body>
</html>