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.
Example
Properties
apiKey
default:
"" |
Gets and sets the MapTiler API key.
Emits the apiKey event when updated. |
---|---|
caching
default:
true |
Starting from v2, MapTiler SDK introduced the caching of tiles and fonts served by MapTiler Cloud, which can represent a large chunk of the data being fetched when browsing a map. This caching leverages modern browsers caching API so it's well-managed and there is no risk of bloating! When we update MapTiler Planet or our official styles, the caching logic will detect it and automatically invalidate older versions of the tiles that were previously cached. Caching greatly improves the performance at load time and positively impact the user experience, for this reason, it is enabled by default. If for debugging purposes or a for a very specific use-case caching needs to be disabled, then it possible. |
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).
|