Quick Start Guide

Get client credentials, install MapLibre GL JS, and render your first GrabMaps map in minutes.

Steps to get started

Create client credentials

Go to the Admin dashboard to create client credentials for each environment, such as development, staging, and production. Store the client ID and client secret in your environment variables.

Create client credentials

Install MapLibre GL JS

Install MapLibre GL JS so your app can load Grab map styles and render interactive maps.

View map setup

Render your first map

Load a Grab map style, choose a starting location, and add controls such as zoom, navigation, and attribution.

Initialize a map
Store client secrets on your server. Exchange them for an access token before loading protected map resources.

Install MapLibre GL JS

Install the package, then fetch the map style before creating the map:

npm install maplibre-gl
import maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';

Request an access token on your server, then use it as a Bearer token when loading protected APIs.

Initialize the map

Use MapLibre GL JS to render GrabMaps tiles.

MapLibre GL JS

Open the demo page to verify your access token, tiles, and attribution are working correctly.

import maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';

// Obtain an access token from your server before loading the map.
const accessToken = '<ACCESS_TOKEN>';

fetch('https://api.maps.grab.com/api/v1/styles/urban-light-partner/descriptor', {
  headers: {
    'Authorization': `Bearer ${accessToken}`
  }
})
.then(response => {
  if (!response.ok) {
    throw new Error('Request failed with HTTP ' + response.status);
  }
  return response.json();
})
.then(style => {
  const map = new maplibregl.Map({
    container: 'map',
    style: style,
    center: [103.8198, 1.3521],
    zoom: 12,
    transformRequest: (url) => {
      const resourceUrl = new URL(url, window.location.href);
      return resourceUrl.origin === 'https://api.maps.grab.com'
        ? { url, headers: { Authorization: `Bearer ${accessToken}` } }
        : { url };
    },
  });

  map.addControl(new maplibregl.NavigationControl(), 'top-right');
});

Next steps

Initializing a map

Create your first interactive map with a Grab style and MapLibre GL JS.

See guide

Search & Discover Places

Add keyword search, nearby place discovery, and reverse geocoding.

See guide

Route & Navigate

Show routes between locations and help users navigate.

See guide

Configure map options

Customize map styles, controls, layers, attribution, and interactions.

See guide
API Reference

Core endpoint

Use this endpoint to load the map style used by MapLibre GL JS.

GET/api/v1/styles/{Style}/descriptor

Returns the selected named map style JSON. Use urban-light-partner as the default style.

// Obtain an access token from your server before loading the map.
const accessToken = '<ACCESS_TOKEN>';

fetch('https://api.maps.grab.com/api/v1/styles/urban-light-partner/descriptor', {
  headers: {
    'Authorization': `Bearer ${accessToken}`
  }
})
.then(response => {
  if (!response.ok) {
    throw new Error('Request failed with HTTP ' + response.status);
  }
  return response.json();
})
.then(style => {
  const map = new maplibregl.Map({
    container: 'map',
    style: style,
    center: [103.8198, 1.3521],
    zoom: 12,
    transformRequest: (url) => {
      const resourceUrl = new URL(url, window.location.href);
      return resourceUrl.origin === 'https://api.maps.grab.com'
        ? { url, headers: { Authorization: `Bearer ${accessToken}` } }
        : { url };
    },
  });

  map.addControl(new maplibregl.NavigationControl(), 'top-right');
});

Was this page helpful?