Configure Map Options

The MapTiles API suite has four core components: style, vector tiles, fonts, and sprites.

Style

Provides a predefined JSON configuration file that defines the visual appearance of the map. The style document follows the Mapbox Style Specification, references vector tiles, fonts, and sprites, and defines how map features are drawn.

Vector Tiles

Deliver structured geographic data for a map area as compact MVT-formatted tiles containing feature geometry and attributes, such as roads and buildings.

Fonts

Provide character shapes (glyphs) in Protocol Buffers (PBF) format for rendering map labels.

Sprites

Provide map iconography, such as points of interest and road shields, as a PNG sprite sheet with a corresponding JSON index.

Basic setup

Fetch the Grab style with an OAuth access token, convert the response to JSON, and pass that object to MapLibre as the map style.

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');
});

Map options

OptionTypeDescription
containerstring | HTMLElementRequired. CSS selector or DOM element for the map container.
styleobjectParsed style JSON from /api/v1/styles/{Style}/descriptor.
center[lng, lat]Initial map center.
zoomnumberInitial zoom level.
pitchnumberCamera pitch in degrees.
bearingnumberCamera bearing in degrees.
minZoom / maxZoomnumberClamp available zoom levels.
maxBoundsLngLatBoundsLikeRestrict panning to a geographic area.

Controls and attribution

ControlUsage
NavigationControlAdd zoom and compass controls.
AttributionControlDisplay map attribution in a compact or expanded format.
GeolocateControlLet users center the map on their current location.
ScaleControlShow a distance scale for the current viewport.

Choose a named map style

Include the style name in /api/v1/styles/{Style}/descriptor. Use urban-light-partner as the default.

const styleName = 'urban-light-partner';
const response = await fetch(
  `https://api.maps.grab.com/api/v1/styles/${styleName}/descriptor`,
  {
    headers: {
      Authorization: 'Bearer <ACCESS_TOKEN>'
    }
  }
);
if (!response.ok) {
  throw new Error('Request failed with HTTP ' + response.status);
}
const style = await response.json();
map.setStyle(style);

Adding data layers

Add GeoJSON sources and layers inside the map's load event to render places, routes, or other shapes.

map.on('load', () => {
  map.addSource('route-line', {
    type: 'geojson',
    data: routeGeoJson
  });

  map.addLayer({
    id: 'route-line-layer',
    type: 'line',
    source: 'route-line',
    paint: {
      'line-color': '#1FBF7F',
      'line-width': 6
    }
  });
});

Full configuration example

Copy this to get a map with viewport, controls, attribution, and an empty places layer.

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

async function initMap() {
  // Obtain an access token from your server before loading the map.
  const accessToken = '<ACCESS_TOKEN>';
  const apiOrigin = new URL('https://api.maps.grab.com/api/v1/styles/urban-light-partner/descriptor').origin;
  const response = await fetch('https://api.maps.grab.com/api/v1/styles/urban-light-partner/descriptor', {
    headers: {
      Authorization: `Bearer ${accessToken}`
    }
  });
  if (!response.ok) {
    throw new Error('Request failed with HTTP ' + response.status);
  }
  const style = await response.json();

  const map = new maplibregl.Map({
    container: 'map',
    style,
    center: [103.8198, 1.3521],
    zoom: 12,
    pitch: 0,
    bearing: 0,
    minZoom: 3,
    maxZoom: 20,
    attributionControl: false,
    interactive: true,
    transformRequest: (url) => {
      const resourceUrl = new URL(url, window.location.href);
      return resourceUrl.origin === apiOrigin
        ? { url, headers: { Authorization: `Bearer ${accessToken}` } }
        : { url };
    }
  });

  map.addControl(new maplibregl.NavigationControl({ visualizePitch: true }), 'top-right');
  map.addControl(new maplibregl.AttributionControl({ compact: true }), 'bottom-right');

  map.on('load', () => {
    map.addSource('selected-places', {
      type: 'geojson',
      data: {
        type: 'FeatureCollection',
        features: []
      }
    });

    map.addLayer({
      id: 'selected-places-point',
      type: 'circle',
      source: 'selected-places',
      paint: {
        'circle-radius': 8,
        'circle-color': '#1FBF7F',
        'circle-stroke-color': '#ffffff',
        'circle-stroke-width': 2
      }
    });
  });

  return map;
}
API Reference

Configuration endpoints

API endpoints used for MapLibre style configuration.

Get Map Style

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

Returns a Mapbox Style Specification-compatible JSON document for the selected named style, including its sources, sprites, glyphs, and layers. Use urban-light-partner as the default style.

Request Parameters

ParameterTypeDescription
StylestringRequired. Specifies the style name. Possible values:
  • urban-light-partner (Default)

Request Sample

curl --request GET \
  'https://api.maps.grab.com/api/v1/styles/urban-light-partner/descriptor' \
  --header 'Authorization: Bearer <ACCESS_TOKEN>'

Response Parameters

The response is a Mapbox Style Specification-compatible document. For complete field behavior, see Mapbox Style.

FieldTypeDescription
versionnumberThe version of the style.
namestringThe name of the style.
metadataobjectThe metadata of the style.
sourcesobjectThe sources used by the style.
spritestringThe sprite resource URL for the style.
glyphsstringThe glyph resource URL template for the style.
layersarrayThe layers included in the style.

Get Sprites

GET/api/v1/styles/{Style}/sprites/{FileName}

Returns the requested sprite sheet image or JSON index for a map style, depending on the FileName parameter.

Request Parameters

ParameterTypeDescription
StylestringRequired. The name of the style. Possible values:
  • urban-light-partner (Default)
  • mono
FileNamestringRequired. The sprite file. Possible values:
  • sprite@2x.png
  • sprite@2x.json
  • sprite.png
  • sprite.json

Request Sample

curl --request GET \
  'https://api.maps.grab.com/api/v1/styles/{Style}/sprites/{FileName}' \
  --header 'Authorization: Bearer <ACCESS_TOKEN>'

Response Parameters

This API returns the sprite JSON index or PNG sprite sheet, depending on the FileName parameter. For more details, see Mapbox Sprites.

Get Glyphs

GET/api/v1/glyphs/{FontStack}/{FontUnicodeRange}

Returns font glyphs for a 256-code-point Unicode range in PBF format for rendering map labels.

Request Parameters

ParameterTypeDescription
FontStackstringRequired. The font family. Possible values:
  • Noto Sans Regular
  • Noto Sans Medium
  • Noto Sans Bold
FontUnicodeRangestringRequired. A range of 256 Unicode code points. The starting range is 0-255, the ending range is 65280-65535, and the start and end values must always be 256 code points apart.

Request Sample

curl --request GET \
  'https://api.maps.grab.com/api/v1/glyphs/{FontStack}/{FontUnicodeRange}' \
  --header 'Authorization: Bearer <ACCESS_TOKEN>'

Response Parameters

The response Content-Type is application/x-protobuf. The body contains the requested glyph range encoded with Protocol Buffers.

Get Vector Tiles

GET/api/v1/tiles/{Tileset}/{Z}/{X}/{Y}

Returns MVT-formatted vector map data in PBF format for a tileset and tile coordinate.

Request Parameters

ParameterTypeDescription
TilesetstringRequired. The source of vector data. Possible values:
  • karta-v3 (Default)
  • karta-mn (Mongolia)
  • karta-qatar (Qatar)
ZintegerRequired. The zoom level. Possible values: 0-14.
XintegerRequired. The x tile coordinate at the specified zoom level.
YintegerRequired. The y tile coordinate at the specified zoom level.

Request Sample

curl --request GET \
  'https://api.maps.grab.com/api/v1/tiles/{Tileset}/{Z}/{X}/{Y}' \
  --header 'Authorization: Bearer <ACCESS_TOKEN>'

Response Parameters

We use the PBF format based on Vector Tiles. For more details, see Vector Tiles.

Previous endpoint paths

The following paths remain supported for backward compatibility. New integrations should use the simplified /api/v1/... paths shown alongside them.

View previous endpoint paths
Previous pathRecommended path
/api/style.json/api/v1/styles/urban-light-partner/descriptor
/api/maps/tiles/v2/styles/{style}.json/api/v1/styles/{Style}/descriptor
/api/maps/tiles/v2/styles/{style}/{file}/api/v1/styles/{Style}/sprites/{FileName}
/api/maps/tiles/v2/fonts/{family}/{range}.pbf/api/v1/glyphs/{FontStack}/{FontUnicodeRange}
/api/maps/tiles/v2/vector/{source}/{z}/{x}/{y}.pbf/api/v1/tiles/{Tileset}/{Z}/{X}/{Y}

Was this page helpful?