Skip to main content

Your First Barikoi Map

The fastest way to get a beautiful, interactive map on any website or app.

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>My First Barikoi Map</title>

<!-- Barikoi GL CSS -->
<link
rel="stylesheet"
href="https://unpkg.com/bkoi-gl@latest/dist/style/bkoi-gl.css"
/>
<!-- Barikoi GL JS -->
<script src="https://unpkg.com/bkoi-gl@latest/dist/iife/bkoi-gl.js"></script>

<style>
body {
margin: 0;
padding: 0;
}
html,
body,
#map {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map"></div>

<script>
const map = new bkoigl.Map({
container: "map",
style: "https://map.barikoi.com/styles/barikoi-light/style.json",
center: [90.4071, 23.7925], // Dhaka (feel free to change)
zoom: 11,
accessToken: "YOUR_BARIKOI_API_KEY", // ← Replace this!
});
</script>
</body>
</html>

Code Breakdown

1. Required Dependencies

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

<!-- Barikoi GL JS - The core mapping library -->
<script src="https://unpkg.com/bkoi-gl@latest/dist/iife/bkoi-gl.js"></script>
ResourcePurpose
bkoi-gl.cssStyles for map UI elements (zoom buttons, attribution, popups, etc.)
bkoi-gl.jsCore JavaScript library that renders the map and handles interactions
Use a specific version in production

Replace @latest with a fixed version like @2.0.4 to avoid unexpected breaking changes.


2. CSS Setup for Full-Screen Map

body {
margin: 0; /* Remove default browser margins */
padding: 0; /* Remove default browser padding */
}

html,
body,
#map {
height: 100%; /* Map container takes full viewport height */
width: 100%; /* Map container takes full viewport width */
}
Why is this necessary?

Without these styles, the map container would have zero height and nothing would be visible. The map needs explicit dimensions to render.


3. Map Container Element

<div id="map"></div>

This empty <div> is where Barikoi GL injects the interactive map canvas. The id="map" must match the container property in the JavaScript initialization.


4. Initialize the Map

const map = new bkoigl.Map({
container: "map", // Target element ID
style: "https://map.barikoi.com/styles/barikoi-light/style.json", // Map style URL
center: [90.4071, 23.7925], // [longitude, latitude]
zoom: 11, // Zoom level (0-22)
accessToken: "YOUR_BARIKOI_API_KEY", // Your API key
});

Configuration Options Explained

OptionTypeDescription
containerstringThe id of the HTML element where the map will render
stylestringURL to a Barikoi map style JSON (defines colors, fonts, layers, etc.)
center[lng, lat]Initial map center coordinates — longitude first!
zoomnumberInitial zoom level: 0 = world view, 22 = building level
accessTokenstringYour Barikoi API key from developer.barikoi.com
Common Mistake: Coordinate Order

Barikoi GL uses [longitude, latitude] (like GeoJSON), not [latitude, longitude] (like Google Maps). Dhaka is [90.4071, 23.7925], not [23.7925, 90.4071].


Quick Reference: Zoom Levels

Zoom LevelWhat You See
0-3Continents / Countries
4-6Large regions
7-10Cities
11-14Neighborhoods
15-18Streets
19-22Buildings