This is the documentation of version 0.64.0. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Type Alias GlobalConfig

    Global configuration for the TomTom Maps SDK.

    Contains essential parameters like API keys, language settings, and display preferences that apply across all SDK services and map functionality.

    This configuration can be set globally using TomTomConfig and will be merged with service-specific configurations, with service configs taking precedence.

    const config: GlobalConfig = {
    apiKey: 'your-api-key',
    commonBaseURL: 'https://api.tomtom.com',
    language: 'en-US',
    displayUnits: {
    distance: { type: 'metric' },
    time: { hours: 'hrs', minutes: 'mins' }
    }
    };
    type GlobalConfig = {
        apiKey: string;
        commonBaseURL: string;
        displayUnits?: DisplayUnits;
        geopoliticalView?: GeopoliticalView;
        language?: Language;
        retry?: RetryConfig;
        sendUserAgentHeader?: boolean;
    }
    Index
    apiKey: string

    TomTom API key for authentication.

    Required for all SDK features. Obtain an API key from the my.tomtom.com.

    None (required)
    
    commonBaseURL: string

    Base URL of every TomTom request: service calls, and the style, tile, sprite and glyph URLs the map fetches.

    Change it only to route those requests through a proxy of your own. Leaving apiKey unset too switches the SDK to proxy-credentials mode, where no key leaves the browser and requests carry the proxy's session cookie.

    It must be https:, or relative to the page; http: is accepted only for a loopback address (localhost, 127.0.0.0/8, [::1]). Otherwise service calls reject, and the map constructor throws, with code INSECURE_BASE_URL.

    "https://api.tomtom.com"
    
    displayUnits?: DisplayUnits

    Custom display units for time and distance.

    Applied to formatDistance and formatDuration utilities, which are used throughout the SDK for displaying map information. If not provided, default unit labels are used.

    geopoliticalView?: GeopoliticalView

    Geopolitical view of the map and of service results: whose perspective disputed territories are shown from.

    Unset, each TomTom API picks the default view for the country the request comes from.

    language?: Language

    Language code for SDK services and map content.

    Accepts IETF language codes (case-insensitive). Affects search results, routing instructions, and map labels.

    "ngt" (Neutral Ground Truth - uses local language for each location)
    
    retry?: RetryConfig

    Configuration for automatic retry on rate-limited (429) responses.

    When set, the SDK automatically retries requests that receive a 429 status code using exponential backoff. A field left out takes its default; undefined disables retrying.

    sendUserAgentHeader?: boolean

    Whether requests to TomTom carry the tomtom-user-agent header, naming the SDK and its version.

    TomTom reads it to tell which SDK versions are in use. Turn it off when that header must not leave the page, or when a proxy of yours should not have to allow it in its CORS preflight answer.

    true