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

    Type Alias GlobalConfig

    The global configuration of the TomTom Maps SDK.

    It holds the API key, language, display preferences and other settings that apply to all SDK services and the map.

    You set it with TomTomConfig. The SDK merges it with each service's configuration, and the service configuration takes 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

    The TomTom API key that authenticates requests.

    All SDK features require it. Get one from my.tomtom.com.

    None (required)
    
    commonBaseURL: string

    The base URL of every TomTom request, for 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. If you also leave apiKey unset, the SDK switches to proxy-credentials mode. No key then leaves the browser, and requests carry the proxy's session cookie.

    It must be absolute and https:. The SDK accepts http: 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, even with validateRequest: false.

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

    Custom display units for time and distance.

    formatDistance and formatDuration apply them, and the SDK uses those utilities to display map information. If you don't set it, the default unit labels apply.

    geopoliticalView?: GeopoliticalView

    The geopolitical view of the map and service results, which sets whose perspective disputed territories are shown from.

    If you don't set it, each TomTom API picks the default view for the country the request comes from.

    language?: Language

    The language of SDK services and map content.

    It accepts IETF language codes, case-insensitive, and affects search results, routing instructions, map labels and traffic incident descriptions.

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

    How the SDK retries rate-limited (429) responses.

    When set, the SDK retries requests that receive a 429 status code with exponential backoff. A field you leave out takes its default. To turn retrying off, set it to undefined.

    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. A map reads it at construction. Its image requests (sprite sheets, raster tiles) never carry the header.

    true