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

attributionControl

  • Type: false | AttributionControlOptions
  • Required: false
  • Default: undefined

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: undefined

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: undefined

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: undefined

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

boxZoom

  • Type: boolean
  • Required: false
  • Default: undefined

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

clickTolerance

  • Type: number
  • Required: false
  • Default: undefined

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: undefined

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: undefined

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: undefined

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: undefined

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

doubleClickZoom

  • Type: boolean
  • Required: false
  • Default: undefined

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

hash

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

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: undefined

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

fitBoundsOptions

  • Type: FitBoundsOptions
  • Required: false
  • Default: undefined

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

interactive

  • Type: boolean
  • Required: false
  • Default: undefined

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: undefined

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

locale

  • Type: Record<string, string>
  • Required: false
  • Default: undefined

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: undefined

logoPosition

  • Type: Position
  • Required: false
  • Default: undefined

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: undefined

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

maxPitch

  • Type: number
  • Required: false
  • Default: undefined

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: undefined

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

minPitch

  • Type: number
  • Required: false
  • Default: undefined

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: undefined

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

pitchWithRotate

  • Type: boolean
  • Required: false
  • Default: undefined

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

canvasContextAttributes

  • Type: WebGLContextAttributesWithType
  • Required: false
  • Default: undefined

Set of WebGLContextAttributes that are applied to the WebGL context of the map. See https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext for more details. contextType can be set to webgl2 or webgl to force a WebGL version. Not setting it, Maplibre will do it's best to get a suitable context.

refreshExpiredTiles

  • Type: boolean
  • Required: false
  • Default: undefined

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: undefined

scrollZoom

  • Type: boolean
  • Required: false
  • Default: undefined

mapStyle

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

trackResize

  • Type: boolean
  • Required: false
  • Default: undefined

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

transformRequest

  • Type: RequestTransformFunction
  • Required: false
  • Default: undefined

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: undefined

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: undefined

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: undefined

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: undefined

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: undefined

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: undefined

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

cooperativeGestures

  • Type: GestureOptions
  • Required: false
  • Default: undefined

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

map:projectiontransition

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.