MapLibreMapOptions
MapLibreMapOptions =
object
Defined in: ui/map.ts:63
The MapLibreMap options object.
Properties
antialias?
optionalantialias:boolean
Defined in: ui/map.ts:120
If true, the gl context will be created with MSAA antialiasing, which can be useful for antialiasing custom layers.
Disabled by default as a performance optimization.
attributionControl?
optionalattributionControl:false|AttributionControlOptions
Defined in: ui/map.ts:95
If set, an AttributionControl will be added to the map with the provided options.
To disable the attribution control, pass false.
Note: showing the logo of MapLibre is not required for using MapLibre.
Default Value
bearing?
optionalbearing:number
Defined in: ui/map.ts:214
The initial bearing (rotation) of the map, measured in degrees counter-clockwise from north. If bearing is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to 0.
Default Value
bearingSnap?
optionalbearingSnap:number
Defined in: ui/map.ts:88
The threshold, measured in degrees, that determines when the map's
bearing will snap to north. For example, with a bearingSnap of 7, if the user rotates
the map within 7 degrees of north, the map will automatically snap to exact north.
Default Value
bounds?
optionalbounds:LngLatBoundsLike
Defined in: ui/map.ts:285
The initial bounds of the map. If bounds is specified, it overrides center and zoom constructor options.
boxZoom?
optionalboxZoom:boolean
Defined in: ui/map.ts:159
If true, the "box zoom" interaction is enabled (see BoxZoomHandler).
Default Value
cancelPendingTileRequestsWhileZooming?
optionalcancelPendingTileRequestsWhileZooming:boolean
Defined in: ui/map.ts:338
Determines whether to cancel, or retain, tiles from the current viewport which are still loading but which belong to a farther (smaller) zoom level than the current one.
* If true, when zooming in, tiles which didn't manage to load for previous zoom levels will become canceled. This might save some computing resources for slower devices, but the map details might appear more abruptly at the end of the zoom.
* If false, when zooming in, the previous zoom level(s) tiles will progressively appear, giving a smoother map details experience. However, more tiles will be rendered in a short period of time.
Default Value
center?
optionalcenter:LngLatLike
Defined in: ui/map.ts:204
The initial geographical centerpoint of the map. If center is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to [0, 0] Note: MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match GeoJSON.
Default Value
clickTolerance?
optionalclickTolerance:number
Defined in: ui/map.ts:281
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 Value
collectResourceTiming?
optionalcollectResourceTiming:boolean
Defined in: ui/map.ts:276
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 Value
container
container:
HTMLElement|string
Defined in: ui/map.ts:81
The HTML element in which MapLibre GL JS will render the map, or the element's string id. The specified element must have no children.
cooperativeGestures?
optionalcooperativeGestures:GestureOptions
Defined in: ui/map.ts:194
If true or set to an options object, the map is only accessible on desktop while holding Command/Ctrl and only accessible on mobile with two fingers. Interacting with the map using normal gestures will trigger an informational screen. With this option enabled, "drag to pitch" requires a three-finger gesture. Cooperative gestures are disabled when a map enters fullscreen using FullscreenControl.
Default Value
crossSourceCollisions?
optionalcrossSourceCollisions:boolean
Defined in: ui/map.ts:271
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 Value
doubleClickZoom?
optionaldoubleClickZoom:boolean
Defined in: ui/map.ts:179
If true, the "double click to zoom" interaction is enabled (see DoubleClickZoomHandler).
Default Value
dragPan?
optionaldragPan:boolean|DragPanOptions
Defined in: ui/map.ts:169
If true, the "drag to pan" interaction is enabled. An Object value is passed as options to DragPanHandler#enable.
Default Value
dragRotate?
optionaldragRotate:boolean
Defined in: ui/map.ts:164
If true, the "drag to rotate" interaction is enabled (see DragRotateHandler).
Default Value
fadeDuration?
optionalfadeDuration:number
Defined in: ui/map.ts:266
Controls the duration of the fade-in/fade-out animation for label collisions after initial map load, 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 Value
failIfMajorPerformanceCaveat?
optionalfailIfMajorPerformanceCaveat:boolean
Defined in: ui/map.ts:110
If true, map creation will fail if the performance of MapLibre GL JS would be dramatically worse than expected
(i.e. a software renderer would be used).
Default Value
fitBoundsOptions?
optionalfitBoundsOptions:FitBoundsOptions
Defined in: ui/map.ts:289
A FitBoundsOptions options object to use only when fitting the initial bounds provided above.
forceWebGL1?
optionalforceWebGL1:boolean
Defined in: ui/map.ts:343
When true, WebGL1 will be used even when WebGL2 is available.
hash?
optionalhash:boolean|string
Defined in: ui/map.ts:72
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.
Default Value
interactive?
optionalinteractive:boolean
Defined in: ui/map.ts:77
If false, no mouse, touch, or keyboard listeners will be attached to the map, so it will not respond to interaction.
Default Value
keyboard?
optionalkeyboard:boolean
Defined in: ui/map.ts:174
If true, keyboard shortcuts are enabled (see KeyboardHandler).
Default Value
locale?
optionallocale:any
Defined in: ui/map.ts:261
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).
Default Value
localIdeographFontFamily?
optionallocalIdeographFontFamily:string|false
Defined in: ui/map.ts:298
Defines a CSS
font-family for locally overriding generation of Chinese, Japanese, and Korean characters.
For these characters, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold).
Set to false, to enable font settings from the map's style for these glyph ranges.
The purpose of this option is to avoid bandwidth-intensive glyph server requests. (See Use locally generated ideographs.)
Default Value
logoPosition?
optionallogoPosition:ControlPosition
Defined in: ui/map.ts:104
A string representing the position of the MapLibre wordmark on the map. Valid options are top-left,top-right, bottom-left, or bottom-right.
Default Value
maplibreLogo?
optionalmaplibreLogo:boolean
Defined in: ui/map.ts:99
If true, the MapLibre logo will be shown.
maxBounds?
optionalmaxBounds:LngLatBoundsLike
Defined in: ui/map.ts:129
If set, the map will be constrained to the given bounds.
maxCanvasSize?
optionalmaxCanvasSize: [number,number]
Defined in: ui/map.ts:331
The canvas' width and height max size. The values are passed as an array where the first element is max width and the second element is max height.
You shouldn't set this above WebGl MAX_TEXTURE_SIZE.
Default Value
maxPitch?
optionalmaxPitch:number|null
Defined in: ui/map.ts:154
The maximum pitch of the map (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.
Default Value
maxTileCacheSize?
optionalmaxTileCacheSize:number|null
Defined in: ui/map.ts:239
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 which can be set using maxTileCacheZoomLevels constructor options.
Default Value
maxTileCacheZoomLevels?
optionalmaxTileCacheZoomLevels:number
Defined in: ui/map.ts:244
The maximum number of zoom levels for which to store tiles for a given source. Tile cache dynamic size is calculated by multiplying maxTileCacheZoomLevels with the approximate number of tiles in the viewport for a given source.
Default Value
maxZoom?
optionalmaxZoom:number|null
Defined in: ui/map.ts:144
The maximum zoom level of the map (0-24).
Default Value
minPitch?
optionalminPitch:number|null
Defined in: ui/map.ts:149
The minimum pitch of the map (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.
Default Value
minZoom?
optionalminZoom:number|null
Defined in: ui/map.ts:139
The minimum zoom level of the map (0-24).
Default Value
pitch?
optionalpitch:number
Defined in: ui/map.ts:219
The initial pitch (tilt) of the map, measured in degrees away from the plane of the screen (0-85). If pitch is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to 0. Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.
Default Value
pitchWithRotate?
optionalpitchWithRotate:boolean
Defined in: ui/map.ts:310
If false, the map's pitch (tilt) control with "drag to rotate" interaction will be disabled.
Default Value
pixelRatio?
optionalpixelRatio:number
Defined in: ui/map.ts:320
The pixel ratio.
The canvas' width attribute will be container.clientWidth * pixelRatio and its height attribute will be container.clientHeight * pixelRatio. Defaults to devicePixelRatio if not specified.
preserveDrawingBuffer?
optionalpreserveDrawingBuffer:boolean
Defined in: ui/map.ts:115
If true, the map's canvas can be exported to a PNG using map.getCanvas().toDataURL(). This is false by default as a performance optimization.
Default Value
refreshExpiredTiles?
optionalrefreshExpiredTiles:boolean
Defined in: ui/map.ts:125
If false, the map won't attempt to re-request tiles once they expire per their HTTP cacheControl/expires headers.
Default Value
renderWorldCopies?
optionalrenderWorldCopies:boolean
Defined in: ui/map.ts:234
If true, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to false:
- When the map is zoomed out far enough that a single representation of the world does not fill the map's entire container, there will be blank space beyond 180 and -180 degrees longitude.
- Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the map and the other on the left edge of the map) at every zoom level.
Default Value
roll?
optionalroll:number
Defined in: ui/map.ts:224
The initial roll angle of the map, measured in degrees counter-clockwise about the camera boresight. If roll is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to 0.
Default Value
rollEnabled?
optionalrollEnabled:boolean
Defined in: ui/map.ts:315
If false, the map's roll control with "drag to rotate" interaction will be disabled.
Default Value
scrollZoom?
optionalscrollZoom:boolean|AroundCenterOptions
Defined in: ui/map.ts:134
If true, the "scroll to zoom" interaction is enabled. AroundCenterOptions are passed as options to ScrollZoomHandler#enable.
Default Value
style?
optionalstyle:StyleSpecification|string
Defined in: ui/map.ts:305
The map's MapLibre style. This must be a JSON object conforming to the schema described in the MapLibre Style Specification, or a URL to such JSON. When the style is not specified, calling MapLibreMap#setStyle is required to render the map.
touchPitch?
optionaltouchPitch:boolean|AroundCenterOptions
Defined in: ui/map.ts:189
If true, the "drag to pitch" interaction is enabled. An Object value is passed as options to TwoFingersTouchPitchHandler#enable.
Default Value
touchZoomRotate?
optionaltouchZoomRotate:boolean|AroundCenterOptions
Defined in: ui/map.ts:184
If true, the "pinch to rotate and zoom" interaction is enabled. An Object value is passed as options to TwoFingersTouchZoomRotateHandler#enable.
Default Value
trackResize?
optionaltrackResize:boolean
Defined in: ui/map.ts:199
If true, the map will automatically resize when the browser window resizes.
Default Value
transformCameraUpdate?
optionaltransformCameraUpdate:CameraUpdateTransformFunction|null
Defined in: ui/map.ts:256
A callback run before the map's camera is moved due to user input or animation. The callback can be used to modify the new center, zoom, pitch and bearing. Expected to return an object containing center, zoom, pitch or bearing values to overwrite.
Default Value
transformRequest?
optionaltransformRequest:RequestTransformFunction|null
Defined in: ui/map.ts:250
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.
Expected to return an object with a url property and optionally headers and credentials properties.
Default Value
validateStyle?
optionalvalidateStyle:boolean
Defined in: ui/map.ts:325
If false, style validation will be skipped. Useful in production environment.
Default Value
zoom?
optionalzoom:number
Defined in: ui/map.ts:209
The initial zoom level of the map. If zoom is not specified in the constructor options, MapLibre GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to 0.