Config

The config object represents the SDK global settings. It exposes properties and options that make it easier to define some values that the SDK will use globally, such as the API key, the map units, etc.

Extends Evented.

Example

Properties

apiKey
default: ""
Gets and sets the MapTiler API key. Emits the apiKey event when updated.
session
default: true
Setting on whether of not the SDK runs with a session logic. A "session" is started at the initialization of the SDK and finished when the browser page is being refreshed. When session is enabled, the extra URL param mtsid is added to queries on the MapTiler Cloud API.
This allows MapTiler to enable "session based billing".
units
default: metric
Gets and sets the map units. When updated, it emits the unit event that is caught inside of the map instances.
Example: to update the scale control
primaryLanguage
default: Language.AUTO
Sets the map primary language, use when a Map instance is created.
(default: the language of the web browser is used)
secondaryLanguage
default: null
Sets the map secondary language, to overwrite the default language defined in the map style. This settings is highly dependant on the style compatibility and may not work in most cases.
fetch
FetchFunction
Gets and sets a the custom fetch function to replace the default one. If the fetch() function exists (browser or Node >= 18) then it will be resolved automatically. A custom fetch() function can be provided for early Node versions (Node < 18).
Reference documentation of MapTiler SDK JS, an extension of MapLibre GL JS