Skip to content

MglMap

The map component

See Map.

typescript
import { MglMap } from '@indoorequal/vue-maplibre-gl';

Props

width

  • Type: number | string
  • Required: false
  • Default: "100%"

Width of the map container

height

  • Type: number | string
  • Required: false
  • Default: "100%"

Height of the map container

antialias

  • Type: boolean
  • Required: false
  • Default: () => defaults.antialias

If 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.

attributionControl

  • Type: false | AttributionControlOptions
  • Required: false
  • Default: () => defaults.attributionControl

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 ts compact: true, customAttribution: "MapLibre ...".

v-model

  • Type: number
  • Required: false
  • Default: () => defaults.zoom

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. Default Value 0

bearingSnap

  • Type: number
  • Required: false
  • Default: () => defaults.bearingSnap

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 7

bounds

  • Type: LngLatBoundsLike
  • Required: false
  • Default: () => defaults.bounds

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

boxZoom

  • Type: boolean
  • Required: false
  • Default: () => defaults.boxZoom

If true, the "box zoom" interaction is enabled (see BoxZoomHandler). Default Value ts true

clickTolerance

  • Type: number
  • Required: false
  • Default: () => defaults.clickTolerance

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 ts true

collectResourceTiming

  • Type: boolean
  • Required: false
  • Default: () => defaults.collectResourceTiming

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 false

crossSourceCollisions

  • Type: boolean
  • Required: false
  • Default: () => defaults.crossSourceCollisions

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 true

dragPan

  • Type: boolean
  • Required: false
  • Default: () => defaults.dragPan

If true, the "drag to pan" interaction is enabled. An Object value is passed as options to DragPanHandler#enable. Default Value true

dragRotate

  • Type: boolean
  • Required: false
  • Default: () => defaults.dragRotate

If true, the "drag to rotate" interaction is enabled (see DragRotateHandler). Default Value true

doubleClickZoom

  • Type: boolean
  • Required: false
  • Default: () => defaults.doubleClickZoom

If true, the "double click to zoom" interaction is enabled (see DoubleClickZoomHandler). Default Value true

hash

  • Type: boolean | string
  • Required: false
  • Default: () => defaults.hash

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 false

fadeDuration

  • Type: number
  • Required: false
  • Default: () => defaults.fadeDuration

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 300

failIfMajorPerformanceCaveat

  • Type: boolean
  • Required: false
  • Default: () => defaults.failIfMajorPerformanceCaveat

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 false

fitBoundsOptions

  • Type: FitBoundsOptions
  • Required: false
  • Default: () => defaults.fitBoundsOptions

A FitBoundsOptions options object to use only when fitting the initial bounds provided above.

interactive

  • Type: boolean
  • Required: false
  • Default: () => defaults.interactive

If false, no mouse, touch, or keyboard listeners will be attached to the map, so it will not respond to interaction. Default Value true

keyboard

  • Type: boolean
  • Required: false
  • Default: () => defaults.keyboard

If true, keyboard shortcuts are enabled (see KeyboardHandler). Default Value true

locale

  • Type: Record<string, string>
  • Required: false
  • Default: () => defaults.locale

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 null

localIdeographFontFamily

  • Type: string
  • Required: false
  • Default: () => defaults.localIdeographFontFamily

logoPosition

  • Type: Position
  • Required: false
  • Default: () => defaults.logoPosition

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 'bottom-left'

maxBounds

  • Type: LngLatBoundsLike
  • Required: false
  • Default: () => defaults.maxBounds

If set, the map will be constrained to the given bounds.

maxPitch

  • Type: number
  • Required: false
  • Default: () => defaults.maxPitch

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 60

maxZoom

  • Type: number
  • Required: false
  • Default: () => defaults.maxZoom

The maximum zoom level of the map (0-24). Default Value 22

minPitch

  • Type: number
  • Required: false
  • Default: () => defaults.minPitch

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 0

minZoom

  • Type: number
  • Required: false
  • Default: () => defaults.minZoom

The minimum zoom level of the map (0-24). Default Value 0

preserveDrawingBuffer

  • Type: boolean
  • Required: false
  • Default: () => defaults.preserveDrawingBuffer

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 false

pitchWithRotate

  • Type: boolean
  • Required: false
  • Default: () => defaults.pitchWithRotate

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

refreshExpiredTiles

  • Type: boolean
  • Required: false
  • Default: () => defaults.refreshExpiredTiles

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

renderWorldCopies

  • Type: boolean
  • Required: false
  • Default: () => defaults.renderWorldCopies

scrollZoom

  • Type: boolean
  • Required: false
  • Default: () => defaults.scrollZoom

mapStyle

  • Type: string | StyleSpecification
  • Required: false
  • Default: () => defaults.style

trackResize

  • Type: boolean
  • Required: false
  • Default: () => defaults.trackResize

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

transformRequest

  • Type: RequestTransformFunction
  • Required: false
  • Default: defaults.transformRequest

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.

transformCameraUpdate (since 6.4.0)

  • Type: CameraUpdateTransformFunction
  • Required: false
  • Default: defaults.transformCameraUpdate

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.

touchZoomRotate

  • Type: boolean
  • Required: false
  • Default: () => defaults.touchZoomRotate

The map's TwoFingersTouchZoomRotateHandler, which allows the user to zoom or rotate the map with touch gestures. Find more details and examples using touchZoomRotate in the TwoFingersTouchZoomRotateHandler section.

touchPitch

  • Type: boolean
  • Required: false
  • Default: () => defaults.touchPitch

The map's TwoFingersTouchPitchHandler, which allows the user to pitch the map with touch gestures. Find more details and examples using touchPitch in the TwoFingersTouchPitchHandler section.

maxTileCacheSize

  • Type: number
  • Required: false
  • Default: () => defaults.maxTileCacheSize

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 null

mapKey

  • Type: string | symbol
  • Required: false
  • Default: undefined

The name or symbol to reference a map via useMap composable

pixelRatio

  • Type: number
  • Required: false
  • Default: () => defaults.pixelRatio

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.

validateStyle (since 6.4.0)

  • Type: boolean
  • Required: false
  • Default: () => defaults.validateStyle

If false, style validation will be skipped. Useful in production environment. Default value true

cooperativeGestures

  • Type: GestureOptions
  • Required: false
  • Default: () => defaults.cooperativeGestures

The map's {@link CooperativeGesturesHandler}, which allows the user to see cooperative gesture info when user tries to zoom in/out. Find more details and examples using cooperativeGestures in the {@link CooperativeGesturesHandler} section.

Events

map:error

map:load

map:idle

map:remove

map:render

map:resize

map:webglcontextlost

map:webglcontextrestored

map:dataloading

map:data

map:tiledataloading

map:sourcedataloading

map:styledataloading

map:sourcedata

map:styledata

map:styleimagemissing

map:dataabort

map:sourcedataabort

map:boxzoomcancel

map:boxzoomstart

map:boxzoomend

map:touchcancel

map:touchmove

map:touchend

map:touchstart

map:click

map:contextmenu

map:dblclick

map:mousemove

map:mouseup

map:mousedown

map:mouseout

map:mouseover

map:movestart

map:move

map:moveend

map:zoomstart

map:zoom

map:zoomend

map:rotatestart

map:rotate

map:rotateend

map:dragstart

map:drag

map:dragend

map:pitchstart

map:pitch

map:pitchend

map:wheel

map:terrain

map:cooperativegestureprevented

update:center

Center property updated

update:zoom

Zoom property updated

update:pitch

Pitch property updated

update:bearing

Bearing property updated

Slots

default

Slot for controls, sources, marker and popup

Source

See source.

Released under the MIT License.