Map class

The control for a visual and interactive web map.

Constructors

Map(string, ServiceOptions & StyleOptions & UserInteractionOptions & CameraOptions | CameraBoundsOptions)

Displays a map in the specified container.

Properties

authentication
controls
events
imageSprite
layers
markers
sources

Methods

areTilesLoaded()

Returns a boolean indicating if all tiles in the current viewport for all sources have loaded or not.

clear()

Removes all user added sources, layers, markers, and popups from the map. User added images are preserved.

dispose()

Clean up the map's resources. Map will not function correctly after calling this method.

getCamera()

Returns the camera's current properties.

getCanvas()

Returns the HTMLCanvasElement that the map is drawn to.

getCanvasContainer()

Returns the HTMLElement that contains the map's HTMLCanvasElement. The map's events (e.g. panning and zooming) are attached to this element.

getMapContainer()

Returns the HTMLElement that contains the map.

getServiceOptions()

Returns the service options with which the map control was initialized.

getStyle()

Returns the map control's current style settings.

getTraffic()

Return the map control's current traffic settings.

getUserInteraction()

Return the map control's current user interaction handler settings.

pixelsToPositions(Pixel[])

Converts an array of Pixel objects to an array of geographic Positions objects on the map.

positionsToPixels(Position[])

Converts an array of Positions objects to an array of Pixel objects relative to the map container.

resize(any)

Resize the map according to the dimensions of its container element.

resize(number | string, number | string, any)

Resizes the map's container element then the map itself.

setCamera(CameraOptions | CameraBoundsOptions & AnimationOptions)

Set the camera of the map control with an animated transition. Any options not specified will default to their current values.

setServiceOptions(ServiceOptions)

Set the service options.

setStyle(StyleOptions)

Set the map control's style options. Any options not specified will default to their current values.

setTraffic(TrafficOptions)

Set the traffic options for the map. Any options not specified will default to their current values.

setUserInteraction(UserInteractionOptions)

Set the map control's user interaction handlers. Any options not specified will default to their current values.

stop()

Stops any animated transition that is currently underway.

Constructor Details

Map(string, ServiceOptions & StyleOptions & UserInteractionOptions & CameraOptions | CameraBoundsOptions)

Displays a map in the specified container.

new Map(container: string, options: ServiceOptions & StyleOptions & UserInteractionOptions & CameraOptions | CameraBoundsOptions)

Parameters

container
string

The id of the element where the map should be displayed.

options
ServiceOptions & StyleOptions & UserInteractionOptions & CameraOptions | CameraBoundsOptions

Options for the initial display and interactability with the map.

Property Details

authentication

authentication: AuthenticationManager

Property Value

controls

controls: ControlManager

Property Value

events

events: EventManager

Property Value

imageSprite

imageSprite: ImageSpriteManager

Property Value

layers

layers: LayerManager

Property Value

markers

markers: HtmlMarkerManager

Property Value

sources

sources: SourceManager

Property Value

Method Details

areTilesLoaded()

Returns a boolean indicating if all tiles in the current viewport for all sources have loaded or not.

function areTilesLoaded()

Returns

boolean

clear()

Removes all user added sources, layers, markers, and popups from the map. User added images are preserved.

function clear()

dispose()

Clean up the map's resources. Map will not function correctly after calling this method.

function dispose()

getCamera()

Returns the camera's current properties.

function getCamera()

Returns

getCanvas()

Returns the HTMLCanvasElement that the map is drawn to.

function getCanvas()

Returns

HTMLCanvasElement

getCanvasContainer()

Returns the HTMLElement that contains the map's HTMLCanvasElement. The map's events (e.g. panning and zooming) are attached to this element.

function getCanvasContainer()

Returns

HTMLElement

getMapContainer()

Returns the HTMLElement that contains the map.

function getMapContainer()

Returns

HTMLElement

getServiceOptions()

Returns the service options with which the map control was initialized.

function getServiceOptions()

Returns

getStyle()

Returns the map control's current style settings.

function getStyle()

Returns

getTraffic()

Return the map control's current traffic settings.

function getTraffic()

Returns

getUserInteraction()

Return the map control's current user interaction handler settings.

function getUserInteraction()

Returns

pixelsToPositions(Pixel[])

Converts an array of Pixel objects to an array of geographic Positions objects on the map.

function pixelsToPositions(pixels: Pixel[])

Parameters

pixels
Pixel[]

The pixels to be converted.

Returns

positionsToPixels(Position[])

Converts an array of Positions objects to an array of Pixel objects relative to the map container.

function positionsToPixels(positions: Position[])

Parameters

positions
Position[]

The positions to be converted.

Returns

Pixel[]

resize(any)

Resize the map according to the dimensions of its container element.

function resize(eventData?: any)

Parameters

eventData
any

Optional additional properties to be added to event objects of events triggered by this method.

resize(number | string, number | string, any)

Resizes the map's container element then the map itself.

function resize(height: number | string, width: number | string, eventData?: any)

Parameters

height
number | string

The height for the map and its container element. A number input is assumed to be in pixels.

width
number | string

The width for the map and its container element. A number input is assumed to be in pixels.

eventData
any

Optional additional properties to be added to event objects of events triggered by this method.

setCamera(CameraOptions | CameraBoundsOptions & AnimationOptions)

Set the camera of the map control with an animated transition. Any options not specified will default to their current values.

function setCamera(options?: CameraOptions | CameraBoundsOptions & AnimationOptions)

Parameters

options
CameraOptions | CameraBoundsOptions & AnimationOptions

The options for setting the map's camera and for the animation of any view change.

setServiceOptions(ServiceOptions)

Set the service options.

function setServiceOptions(options: ServiceOptions)

Parameters

options
ServiceOptions

setStyle(StyleOptions)

Set the map control's style options. Any options not specified will default to their current values.

function setStyle(options?: StyleOptions)

Parameters

options
StyleOptions

The options for setting the style of the map control.

setTraffic(TrafficOptions)

Set the traffic options for the map. Any options not specified will default to their current values.

function setTraffic(options?: TrafficOptions)

Parameters

options
TrafficOptions

The options for defining the map's traffic display.

setUserInteraction(UserInteractionOptions)

Set the map control's user interaction handlers. Any options not specified will default to their current values.

function setUserInteraction(options?: UserInteractionOptions)

Parameters

options
UserInteractionOptions

The options for enabling/disabling the user interaction handlers.

stop()

Stops any animated transition that is currently underway.

function stop()