Interface MapOptions

Objects that implement this interface will create or interact with the map control.

See

Mapbox Map Parameters

Hierarchy

  • Omit<MapboxOptionsGL, "accessToken" | "attributionControl" | "container" | "customAttribution" | "style">
    • MapOptions

Properties

accessToken: string

The access token that will be used to retrieve data from the Mapbox server.

See

Access Tokens

antialias?: boolean

If true, the gl context will be created with MSA antialiasing, which can be useful for antialiasing custom layers. This is false by default as a performance optimization.

bearing?: number
bearingSnap?: number

Snap to north threshold in degrees.

bounds?: LngLatBoundsLike

The initial bounds of the map. If bounds is specified, it overrides center and zoom constructor options.

boxZoom?: boolean

If true, enable the "box zoom" interaction (see BoxZoomHandler)

center?: LngLatLike

initial map center

clickTolerance?: number

The max number of pixels a user can shift the mouse pointer during a click for it to be considered a valid click (as opposed to a mouse drag).

Default

3
collectResourceTiming?: boolean

If true, Resource Timing API information will be collected for requests made by GeoJSON and Vector Tile web workers (this information is normally inaccessible from the main Javascript thread). Information will be returned in a resourceTiming property of relevant data events.

Default

false
crossSourceCollisions?: boolean

If true, symbols from multiple sources can collide with each other during collision detection. If false, collision detection is run separately for the symbols in each source.

Default

true
cssFile?: string

The URL to a mapbox CSS file (not to be confused with the map style). The CSS URL will be added to the page's <head> element at runtime. An example URL //api.tiles.mapbox.com/mapbox-gl-js/v1.6.1/mapbox-gl.css.

See

doubleClickZoom?: boolean

If true, enable the "double click to zoom" interaction (see DoubleClickZoomHandler).

dragPan?: boolean

If true, enable the "drag to pan" interaction (see DragPanHandler).

dragRotate?: boolean

If true, enable the "drag to rotate" interaction (see DragRotateHandler).

fadeDuration?: number

Controls the duration of the fade-in/fade-out animation for label collisions, in milliseconds. This setting affects all symbol layers. This setting does not affect the duration of runtime styling transitions or raster tile cross-fading.

Default

300
failIfMajorPerformanceCaveat?: boolean

If true, map creation will fail if the implementation determines that the performance of the created WebGL context would be dramatically lower than expected.

fitBoundsOptions?: FitBoundsOptions

A fitBounds options object to use only when setting the bounds option.

hash?: string | boolean

If true, the map's position (zoom, center latitude, center longitude, bearing, and pitch) will be synced with the hash fragment of the page's URL. For example, http://path/to/my/page.html#2.59/39.26/53.07/-24.1/60. An additional string may optionally be provided to indicate a parameter-styled hash, e.g. http://path/to/my/page.html#map=2.59/39.26/53.07/-24.1/60&foo=bar, where foo is a custom parameter and bar is an arbitrary hash distinct from the map hash.

interactive?: boolean

If false, no mouse, touch, or keyboard listeners are attached to the map, so it will not respond to input

keyboard?: boolean

If true, enable keyboard shortcuts (see KeyboardHandler).

localFontFamily?: string

Overrides the generation of all glyphs and font settings except font-weight keywords Also overrides localIdeographFontFamily

Default

null
localIdeographFontFamily?: string

If specified, defines a CSS font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs' and 'Hangul Syllables' ranges. In these ranges, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold). The purpose of this option is to avoid bandwidth-intensive glyph server requests.

Default

null
locale?: {
    [key: string]: string;
}

A patch to apply to the default localization table for UI strings, e.g. control tooltips. The locale object maps namespaced UI string IDs to translated strings in the target language; see src/ui/default_locale.js for an example with all supported string IDs. The object may specify all UI strings (thereby adding support for a new translation) or only a subset of strings (thereby patching the default translation table).

Type declaration

  • [key: string]: string
logoPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right"

A string representing the position of the Mapbox wordmark on the map.

Default

"bottom-left"
mapStyle?: string | Style

The mapbox style to use when rendering the map (not to be confused with the CSS file). A Style object, ID, or URL. Commonly a URL like mapbox://styles/mapbox/outdoors-v11.

See

maxBounds?: LngLatBoundsLike

If set, the map is constrained to the given bounds.

maxPitch?: number

Maximum pitch of the map.

maxTileCacheSize?: number

The maximum number of tiles stored in the tile cache for a given source. If omitted, the cache will be dynamically sized based on the current viewport.

Default

null
maxZoom?: number

Maximum zoom of the map.

minPitch?: number

Minimum pitch of the map.

minZoom?: number

Minimum zoom of the map.

optimizeForTerrain?: boolean

If true, map will prioritize rendering for performance by reordering layers If false, layers will always be drawn in the specified order

Default

true
pitch?: number

The initial pitch (tilt) of the map, measured in degrees away from the plane of the screen (0-60).

Default

0
pitchWithRotate?: boolean

If false, the map's pitch (tilt) control with "drag to rotate" interaction will be disabled.

Default

true
preserveDrawingBuffer?: boolean

If true, The maps canvas can be exported to a PNG using map.getCanvas().toDataURL();. This is false by default as a performance optimization.

refreshExpiredTiles?: boolean

If false, the map won't attempt to re-request tiles once they expire per their HTTP cacheControl/expires headers.

Default

true
renderWorldCopies?: boolean

If true, multiple copies of the world will be rendered, when zoomed out.

Default

true
scrollZoom?: boolean

If true, enable the "scroll to zoom" interaction

touchPitch?: boolean

If true, the "drag to pitch" interaction is enabled

touchZoomRotate?: boolean

If true, enable the "pinch to rotate and zoom" interaction (see TouchZoomRotateHandler).

trackResize?: boolean

If true, the map will automatically resize when the browser window resizes

transformRequest?: TransformRequestFunction

A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests.

Default

null
zoom?: number

Initial zoom level

Generated using TypeDoc