Map

Basic usage

Mapbox streets

API

Props

NameDescriptionTypeDefault
hashIf 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.string/booleanfalse
interactiveIf false, no mouse, touch, or keyboard listeners will be attached to the map, so it will not respond to interaction.booleantrue
bearingSnapThe 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.number7
attributionControlIf set, an AttributionControl will be added to the map with the provided options.booleantrue
maplibreLogoIf true, the MapLibre logo will be shown.booleanfalse
logoPositionA string representing the position of the MapLibre wordmark on the map.enumbottom-left
failIfMajorPerformanceCaveatIf true, map creation will fail if the performance of MapLibre GL JS would be dramatically worse than expected.booleanfalse
preserveDrawingBufferIf true, the map's canvas can be exported to a PNG using map.getCanvas().toDataURL(). This is false by default as a performance optimization.booleanfalse
antialiasIf true, the gl context will be created with MSAA antialiasing, which can be useful for antialiasing custom layers. This is false by default as a performance optimization.booleanfalse
refreshExpiredTilesIf false, the map won't attempt to re-request tiles once they expire per their HTTP cacheControl/expires headers.booleantrue
maxBoundsIf set, the map will be constrained to the given bounds.object / array-
scrollZoomIf true, the "scroll to zoom" interaction is enabled. AroundCenterOptions are passed as options to ScrollZoomHandler#enable.boolean / objecttrue
minZoomThe minimum zoom level of the map (0-24).number0
maxZoomThe maximum zoom level of the map (0-24).number22
minPitchThe 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.number0
maxPitchThe 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.number60
boxZoomIf true, the "box zoom" interaction is enabled (see BoxZoomHandler).booleantrue
dragRotateIf true, the "drag to rotate" interaction is enabled (see DragRotateHandler).booleantrue
dragPanIf true, the "drag to pan" interaction is enabled. An Object value is passed as options to DragPanHandler#enable.boolean / objecttrue
keyboardIf true, keyboard shortcuts are enabled (see KeyboardHandler).booleantrue
doubleClickZoomIf true, the "double click to zoom" interaction is enabled (see DoubleClickZoomHandler).booleantrue
touchZoomRotateIf true, the "pinch to rotate and zoom" interaction is enabled. An Object value is passed as options to TwoFingersTouchZoomRotateHandler#enable.boolean / Objecttrue
touchPitchIf true, the "drag to pitch" interaction is enabled. An Object value is passed as options to TwoFingersTouchPitchHandler#enable.boolean / Objecttrue
cooperativeGesturesIf 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.boolean / Object-
trackResizeIf true, the map will automatically resize when the browser window resizes.booleantrue
centerThe 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.object / array[0, 0]
zoomThe 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.number0
bearingThe 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.number0
pitchThe 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.number0
renderWorldCopiesIf true, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude.booleantrue
maxTileCacheSizeThe 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.number-
maxTileCacheZoomLevelsThe 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.number5
transformRequestA 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.Function-
transformCameraUpdateA 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.Function-
localeA 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).object-
fadeDurationControls 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.number300
crossSourceCollisionsIf 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.booleantrue
collectResourceTimingIf 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.booleanfalse
clickToleranceThe 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).number-
boundsThe initial bounds of the map. If bounds is specified, it overrides center and zoom constructor options.object / array-
fitBoundsOptionsA FitBoundsOptions options object to use only when fitting the initial bounds provided above.object-
localIdeographFontFamilyDefines a CSS font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs', 'Hiragana', 'Katakana' 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). 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.)string / boolean'sans-serif'
mapStyleThe 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.object / string-
pitchWithRotateIf false, the map's pitch (tilt) control with "drag to rotate" interaction will be disabled.booleantrue
pixelRatioThe 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.numberwindow.devicePixelRatio
validateStyleIf false, style validation will be skipped. Useful in production environment.booleantrue
maxCanvasSizeThe 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. Defaults to [4096, 4096].array[4096, 4096]
containerIdThe HTML element's string id, which MapLibre GL JS will render the map.string'mapContainer'
eventLayerIdThe ID of a style layer. if provided this, Event will only be triggered if its location is within a visible feature in this layer. Compatible with eventLayerId: mousedown, mouseup, mouseover, mouseout, mousemove, mouseenter(required), mouseleave(required), click, dblclick, contextmenu, touchstart, touchend, touchcancelstring-

Events

NameDescriptionType
beforeLoadTriggers before the maplibreObject is loaded.Function
readyTriggers when the maplibreObject is successfully loaded.Function
unreadyTriggers when the maplibreObject loading failed.Function
destroyedTriggers when the maplibreObject is destroyed.Function
update:zoomTriggers when the zoom changed.Function
update:centerTriggers when the center changed.Function
update:bearingTriggers when the bearing changed.Function
update:pitchTriggers when the pitch changed.Function
touchEndTriggers when touch end.Function

Slots

NameDescription
defaultDefault slot content of the vm-map component.

Exposes

NameDescriptionType
loadLoad the component manually.Function
unloadDestroy the loaded component manually.Function
reloadLoad the component manually.Function
creatingPromiseDetermine whether the component is created by this.object
maplibreObjectThe maplibreObject created by component.object
getMaplibreObjectGet the maplibreObject created by component.Function

Source

ComponentDocs

Contributors