Skip to main content

Display Custom Map Style

Pick your vibe. One line of code changes everything.


Official & Community Styles

Style NamePreview MoodStyle URLBest For
Barikoi LightClean, professionalhttps://map.barikoi.com/styles/barikoi-light/style.jsonDefault, dashboards, web apps
Barikoi Dark ModeSleek, modern, night-friendlyhttps://map.barikoi.com/styles/barikoi-dark-mode/style.jsonAdmin panels, logistics, dark UIs
Barikoi GreenFresh, nature-inspiredhttps://map.barikoi.com/styles/barkoi_green/style.jsonEco apps, agriculture, tourism
Planet MapCommon, realistichttps://map.barikoi.com/styles/planet_map/style.jsonReal estate, urban planning
OSM LibertyOpenStreetMap elegant forkhttps://map.barikoi.com/styles/osm-liberty/style.jsonOpen-data lovers, clean minimalism
Authentication

All styles require your API key via ?key=YOUR_KEY in production (or pass accessToken in JS).


Full Working Example

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Display custom map style</title>
<link
rel="stylesheet"
href="https://unpkg.com/bkoi-gl@latest/dist/style/bkoi-gl.css"
/>
<script src="https://unpkg.com/bkoi-gl@latest/dist/iife/bkoi-gl.js"></script>
<style>
body,
html,
#map {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map"></div>

<script>
const map = new bkoigl.Map({
container: "map",
center: [90.4071, 23.7925], // Dhaka
zoom: 10,
accessToken: "YOUR_BARIKOI_API_KEY",

// Pick any style below — just replace!
style: "https://map.barikoi.com/styles/barikoi-dark-mode/style.json",
});
</script>
</body>
</html>

Code Breakdown

1. Required Dependencies

<!-- CSS for map controls, popups, markers styling -->
<link
rel="stylesheet"
href="https://unpkg.com/bkoi-gl@latest/dist/style/bkoi-gl.css"
/>

<!-- Core Barikoi GL mapping library -->
<script src="https://unpkg.com/bkoi-gl@latest/dist/iife/bkoi-gl.js"></script>

These are the same dependencies used in every Barikoi map. The CSS ensures UI elements render correctly regardless of which style you choose.


2. Full-Screen Map Container

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

This makes the map fill the entire browser window. You can also use fixed dimensions:

#map {
width: 800px;
height: 500px;
}

3. Map Initialization with Custom Style

const map = new bkoigl.Map({
container: "map", // HTML element ID to render the map
center: [90.4071, 23.7925], // Starting position [longitude, latitude]
zoom: 10, // Initial zoom level
accessToken: "YOUR_BARIKOI_API_KEY", // Required for authentication

// 👇 THIS IS THE KEY LINE — change the style URL to switch themes!
style: "https://map.barikoi.com/styles/barikoi-dark-mode/style.json",
});

The style Property Explained

PropertyDescription
What it isA URL pointing to a JSON file that defines every visual aspect of the map
What it controlsColors, fonts, layer visibility, road widths, label placement, icons
How to changeSimply swap the URL to a different style

Switching Styles Dynamically

You can change the map style after initialization using the setStyle() method:

// Switch to dark mode on button click
document.getElementById("darkBtn").addEventListener("click", () => {
map.setStyle(
"https://map.barikoi.com/styles/barikoi-dark-mode/style.json?key=YOUR_BARIKOI_API_KEY"
);
});

document.getElementById("lightBtn").addEventListener("click", () => {
map.setStyle(
"https://map.barikoi.com/styles/barikoi-light/style.json?key=YOUR_BARIKOI_API_KEY"
);
});
Note

Calling setStyle() will remove any custom layers, markers, or sources you've added. You'll need to re-add them after the style loads using the style.load event.


Style Comparison

When to Use Each Style

Style✅ Best For
Barikoi LightGeneral purpose, public-facing apps
Barikoi Dark ModeNight mode, dashboards, admin panels
Barikoi GreenEnvironmental apps, parks, tourism
Planet MapDetailed city exploration
OSM LibertyOpen-source projects, minimal look