Перейти к основному содержимому

class

Circle

Class for creating a circle on the map

Extends: Evented<DynamicObjectEventTable<Circle>>

new constructor(map, options)

Example:

const circle = new mapgl.Circle(map, {
coordinates: map.getCenter(),
radius: 500,
});
Parameters

map

Map<>

The map instance

options

Circle options

Returns
Circle<>
Methods

destroy

Destroys the circle

Returns
void

emit(type, data?)

Calls all event listeners with event type type

Parameters

type

K

Event type

data?

DynamicObjectEventTable<Circle>[K]

Data transferred to events

Returns
this

off(type, listener)

Removes event listener registered with on

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Circle>[K]) => void

Event handler

Returns
this

on(type, listener)

Registers event listener

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Circle>[K]) => void

Event handler

Returns
this

once(type, listener)

Registers event listener which will be called once

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Circle>[K]) => void

Event handler

Returns
this

CircleMarker

Class for creating a circleMarker on the map

The CircleMarker differs from the Circle in that it has radius in pixels so its instance displays the same on any zoom level

Extends: Evented<DynamicObjectEventTable<CircleMarker>>

new constructor(map, options)

Example:

const circleMarker = new mapgl.CircleMarker(map, {
coordinates: map.getCenter(),
radius: 500,
});
Parameters

map

Map<>

The map instance

options

CircleMarker options

Returns
CircleMarker<>
Methods

destroy

Destroys the circleMarker

Returns
void

emit(type, data?)

Calls all event listeners with event type type

Parameters

type

K

Event type

data?

DynamicObjectEventTable<CircleMarker>[K]

Data transferred to events

Returns
this

off(type, listener)

Removes event listener registered with on

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<CircleMarker>[K]) => void

Event handler

Returns
this

on(type, listener)

Registers event listener

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<CircleMarker>[K]) => void

Event handler

Returns
this

once(type, listener)

Registers event listener which will be called once

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<CircleMarker>[K]) => void

Event handler

Returns
this

Control

Class for the map's controls creating.

new constructor(map, content, options?)

Example:

const control = new mapgl.Control(
map,
'<button>Some text</button>',
{ position: 'topLeft' },
);
Parameters

map

Map<>

The map instance.

content

string|HTMLElement<>

Control HTML content.

options?

Control options.

Returns
Control<>
Methods

destroy

Destroys the control.

Returns
void

getContainer

Returns the container of the control.

Returns
HTMLDivElement<>

getPosition

Returns the position of the control.

setPosition(position)

Sets the position of the control.

Parameters

position

Required position of the control.

Returns
void

DefaultSource

The default data source for the map. It's created automatically while the map initializing.

new constructor(map)

Parameters

map

Map<>

The map instance

Returns
DefaultSource<>
Methods

setFeatureStateMap(featureStateMap)

Sets the feature state map to the source.

Example:

source.setFeatureStateMap({
"70030076195691401": { "height": 300 },
"70030076130722099": { "height": 200 },
});
Parameters

featureStateMap

Map of feature state by objects ids

Returns
void

Evented

Event emitter

new constructor

Event emitter class is used internally by the map.

Returns
Evented<M>
Methods

emit(type, data?)

Calls all event listeners with event type type

Parameters

type

K

Event type

data?

M[K]

Data transferred to events

Returns
this

off(type, listener)

Removes event listener registered with on

Parameters

type

K

Event type

listener

(ev: M[K]) => void

Event handler

Returns
this

on(type, listener)

Registers event listener

Parameters

type

K

Event type

listener

(ev: M[K]) => void

Event handler

Returns
this

once(type, listener)

Registers event listener which will be called once

Parameters

type

K

Event type

listener

(ev: M[K]) => void

Event handler

Returns
this

FloorControl

A control for change floor layer level on the map. It appears on the map only if you set the floorControl option within

Extends: Control

new constructor(map, options)

Parameters

map

Map<>

options

Returns
FloorControl<>
Methods

destroy

Destroys the control.

Returns
void

getContainer

Returns the container of the control.

Returns
HTMLDivElement<>

getPosition

Returns the position of the control.

setPosition(position)

Sets the position of the control.

Parameters

position

Required position of the control.

Returns
void

GeoJsonSource

Class for creating GeoJSON data source in the map.

new constructor(map, options)

Example:

const source = new GeoJsonSource(map, {
data: {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
properties: {},
geometry: {
type: 'Point',
coordinates: [82.92186, 55.03029],
},
},
],
},
});
Parameters

map

Map<>

The map instance

options

Spatial data source options

Returns
GeoJsonSource<>
Methods

destroy

Destroys the source

Returns
void

getAttributes

Gets the source attributes

setAttributes(attributes)

Sets the source attributes

Parameters

attributes

Returns
this

setData(data)

Sets source data

Parameters

data

Feature<Geometry, GeoJsonProperties>|FeatureCollection<Geometry, GeoJsonProperties>
Returns
Promise<void>

GeoJsonViewportSource

Class for creating GeoJSON viewport data source in the map.

new constructor(map, options)

Example:

const source = new GeoJsonViewportSource(map, {
data: (bbox) => `http://...&outputFormat=application%2Fjson&bbox=${bbox}&srcName=EPSG:4326`,
});
Parameters

map

Map<>

The map instance

options

Initialization options

Returns
GeoJsonViewportSource<>
Methods

destroy

Destroys the source.

Returns
void

getAttributes

Gets the source attributes.

setAttributes(attributes)

Sets the source attributes.

Parameters

attributes

Returns
this

setData(data)

Sets the source data bbox function.

The bbox parameter is automatically calculated based on the visible viewport and the viewportPadding option.

Parameters

data

(bbox: number[]) => string
Returns
Promise<void>

setViewportPadding(viewportPadding)

Sets the viewport padding to increase the viewport-based area to get data.

Parameters

viewportPadding

number
Returns
this

HtmlMarker

Class for creating an HTML marker on the map.

new constructor(map, options)

Example:

const htmlMarker = new mapgl.HtmlMarker(map, {
coordinates: map.getCenter(),
html: '<div>Some content</div>',
});
Parameters

map

Map<>

The map instance.

options

HtmlMarker options.

Returns
HtmlMarker<>
Methods

destroy

Destroys the HTML marker.

Returns
void

getAnchor

Returns the HTML marker's anchor in pixels.

Returns
number[]

getContent

Returns the whole HTMLElement of the marker. Previously specified HTML content is a child of the element.

Returns
HTMLElement<>

getCoordinates

Returns current position of the top-left corner of the HTML marker with its anchor in geographical coordinates [longitude, latitude] .

Returns
number[]

getZIndex

Returns the z-index CSS property value of the HTML marker's root DOM element.

Returns
number

setAnchor(anchor)

Sets the anchor relative to the top-left corner of the HTML marker.

Parameters

anchor

number[]

An anchor of the HTML marker in pixels.

Returns
this

setContent(html)

Sets the HTML content of the HTML marker.

Parameters

html

string|HTMLElement<>

The content that will replace the current content of the HTML marker.

Returns
this

setCoordinates(coordinates)

Sets the geographical coordinates of the HTML marker.

Parameters

coordinates

number[]

Coordinates [longitude, latitude] where the top-left corner of the HTML marker with its anchor should be set.

Returns
this

setZIndex(zIndex)

Sets the z-index CSS property value of the HTML marker's root DOM element.

Parameters

zIndex

number

The z-index property value.

Returns
this

Label

Class for creating labels on the map.

Extends: Evented<DynamicObjectEventTable<Label>>

new constructor(map, options)

Example:

const label = new mapgl.Label(map, {
coordinates: map.getCenter(),
text: 'There is hope',
color: '#ff0000',
fontSize: 24,
});
Parameters

map

Map<>

The map instance.

options

Label options.

Returns
Label<>
Methods

destroy

Destroys the label.

Returns
void

emit(type, data?)

Calls all event listeners with event type type

Parameters

type

K

Event type

data?

DynamicObjectEventTable<Label>[K]

Data transferred to events

Returns
this

getCoordinates

Returns geographical coordinates [longitude, latitude] of the label.

Returns
number[]

hide

Hides the label.

Returns
this

off(type, listener)

Removes event listener registered with on

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Label>[K]) => void

Event handler

Returns
this

on(type, listener)

Registers event listener

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Label>[K]) => void

Event handler

Returns
this

once(type, listener)

Registers event listener which will be called once

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Label>[K]) => void

Event handler

Returns
this

setCoordinates(coordinates)

Sets geographical coordinates of the label.

Parameters

coordinates

number[]

Coordinates [longitude, latitude] where the center of the label with its anchor should be set.

Returns
this

show

Displays hidden label.

Returns
this

LngLatBoundsClass

A LngLatBoundsClass class represents a geographical bounding box (LngLatBounds), defined by its southwest and northeast points in longitude and latitude with some additional methods

new constructor(params)

Example:

const lngLatBounds = new mapgl.LngLatBoundsClass({
southWest: [0, 0],
northEast: [1, 1],
});
Parameters

params

southWest and northEast points

Returns
LngLatBoundsClass<>
Methods

containsBounds(bounds)

Returns true if the geographical bounding box contains the bounds entirely.

Note that two equal bounds contain each other.

Example to check overlapping:

const bounds = new mapgl.LngLatBoundsClass({
southWest: [1, 1],
northEast: [2, 2],
});
const biggerBounds = new mapgl.LngLatBoundsClass({
southWest: [0.9, 0.9],
northEast: [2.1, 2.1],
});

// false: doesn't overlap but intersects (bounds.intersects(biggerBounds) === true)
const res1 = bounds.containsBounds(biggerBounds);

// true: overlaps and intersects (biggerBounds.intersects(bounds) === true)
const res2 = biggerBounds.containsBounds(bounds);
Parameters

bounds

Bounds to check.

Returns
boolean

containsPoint(point)

Returns true if the geographical bounding box contains the point.

Parameters

point

number[]

Point to check.

Returns
boolean

extend(point)

Extend the bounds to include a given point.

Parameters

point

number[]

The geographical coordinates [lng, lat] .

Returns
this

getCenter

Returns the center point of the geographical bounding box.

Returns
number[]

intersects(bounds)

Returns true if the geographical bounding box intersects the bounds.

Note that two equal bounds intersect each other.

Parameters

bounds

Bounds to check.

Returns
boolean

Map

The main class for map initialization.

Extends: Evented<MapEventTable>

new constructor(container, options)

Example:

const map = new mapgl.Map('map', {
center: [55.185346, 25.14226],
zoom: 16,
});
Parameters

container

string|HTMLElement<>

The HTML element in which the map appears, or its ID.

options

Map initialization options.

Returns
Map<>
Methods

addIcon(name, config)

Adds a config of user icon that will be used in the current style. If an icon with the same name already exists, it won't be added and applied to the current style.

Parameters

name

string

A user icon name.

config

A config with parameters for user icon.

Returns
this

addLayer(layer, beforeId?)

Adds a style layer to the current map style.

Parameters

layer

Layer<>

Style layer object.

beforeId?

string

The identifier of an existing layer to insert the new layer before, resulting in the new layer appearing visually beneath the existing layer. If this argument is not specified, the layer will be appended to the end of the layers array and appear visually above all other layers.

Throws an error if:

  • the layer with specified id already exists in the current map style;
  • the layer with specified beforeId doesn't exist in the current map style;
  • one group layer is inserted into another group layer.
Returns
this

destroy

Destroys the map and frees all related resources.

Returns
void

emit(type, data?)

Calls all event listeners with event type type

Parameters

type

K

Event type

data?

MapEventTable[K]

Data transferred to events

Returns
this

fitBounds(bounds, options?)

Pans and zooms the map to contain its visible area within the specified geographical bounds. This method also resets the map pitch and rotation to 0. But the map rotation can be saved by option considerRotation

Parameters

bounds

The geographical bounds to fit in

options?

FitBounds options

Returns
this

getBounds(options?)

Returns the geographical bounds visible in the current map view.

Parameters

options?

Returns
LngLatBoundsClass<>

getCanvas

Returns HTMLCanvasElement of the map.

Returns
HTMLCanvasElement<>

getCenter

Returns the current map center in geographical coordinates ( [longitude, latitude] ).

Returns
number[]

getContainer

Returns HTML-container of the map.

Returns
HTMLElement<>

getControlsLayoutPadding

Gets current padding of controls layout.

Returns

getDefaultSource

Returns the map default source.

Returns
DefaultSource<>

getGraphicsPreset

Returns graphics preset descriptor.

Returns
GraphicsPreset<>

getLanguage

Returns the desired map language.

Returns
string

getMaxZoom

Returns the current maximum map zoom.

Returns
number

getMinZoom

Returns the current minimum map zoom.

Returns
number

getOption(option)

Gets a value of the map option.

Parameters

option

Map option name. Only 'disableDragging', 'enableTrackResize' options are available

Returns
undefinedboolean

getPadding

Returns the current map padding.

Returns

getPitch

Returns the current map pitch in degrees.

Returns
number

getProjectionMatrix

Returns the view projection matrix associated with the current state of the map.

Returns
number[]

getRotation

Returns the current map rotation in degrees.

Returns
number

getSize

Returns the current map size in logical pixels.

Returns
number[]

getStyleState

Returns the current map style variables.

Returns

getStyleZoom

Returns the current map style zoom.

Returns
number

getWebGLContext

Returns WebGLRenderingContext of the map canvas.

getZoom

Returns the current map zoom.

Returns
number

hasLayer(layerId)

Checks if a style layer or group with the given identifier exists in the current map style.

Parameters

layerId

string

The identifier of a layer or group.

Returns
boolean

hideLayers(params)

Hides the layer or all layers in a group in the current map style and updates the active layers. If only the id is specified, the corresponding layer or group will be hidden by id. If only the type is specified, all layers with this type will be hidden. If both the layer type and id are specified, layers will be hidden by type, and the id will be ignored.

Parameters

params

Returns
this

hideTraffic

Hides the traffic layer from the map.

Returns
this

invalidateSize

Updates the map size. This method should be called after any change in the map container size.

Returns
this

isIdle

Returns true if the map isn't moving and has rendered all the viewport tiles.

Returns
boolean

isTrafficOn

Returns true if the traffic layer is currently enabled on the map.

Returns
boolean

off(type, listener)

Removes event listener registered with on

Parameters

type

K

Event type

listener

(ev: MapEventTable[K]) => void

Event handler

Returns
this

on(type, listener)

Registers event listener

Parameters

type

K

Event type

listener

(ev: MapEventTable[K]) => void

Event handler

Returns
this

once(type, listener)

Registers event listener which will be called once

Parameters

type

K

Event type

listener

(ev: MapEventTable[K]) => void

Event handler

Returns
this

patchStyleState(styleState)

Patches map style global variables. Use this method if you want to change a particular variable and left other ones intact.

Parameters

styleState

Returns
this

project(lngLat)

Returns pixel coordinates [x, y, z] , relative to the map's container, that correspond to the specified geographical coordinates.

Z coordinate is deprecated.

Parameters

lngLat

number[]

The geographical coordinates [longitude, latitude] to project.

Returns
number[]

removeIcon(name)

Removes a specified icon from the current style.

Parameters

name

string

An icon name to remove.

Returns
this

removeLayer(layerId)

Removes the layer with the given identifier from the current map style.

Parameters

layerId

string

The identifier of the layer to remove.

Throws an error if layer with specified id does not exist in the current map style.

Returns
this

setCenter(center, options?)

Sets the geographical center of the map.

Parameters

center

number[]

The desired coordinates ( [longitude, latitude] ).

options?

Center animation options.

Returns
this

setControlsLayoutPadding(padding)

Sets padding for controls layout.

Parameters

padding

Partial<Padding>
Returns
void

setFloorPlanLevel(floorPlanId, floorLevelIndex)

Sets a floorLevel of the floorPlan.

Parameters

floorPlanId

string

id of the floor plan

floorLevelIndex

number

floorLevelIndex in floorLevels list

Returns
void

setLanguage(lang)

Sets the desired map language.

Parameters

lang

string

short string code 'en', 'ru', ...etc

Returns
Map<>

setLowZoomMaxPitch(pitch, options?)

Sets the maximum map pitch for low zooms (zoom < 16.5).

Parameters

pitch

number

The desired maximum pitch in degrees.

options?

Options for animating the pitch in case the current pitch is bigger than the new maximum.

Returns
this

setMaxBounds(bounds)

Sets a bound to limit movings on map

Parameters

bounds

2 lon-lat points to limit square

Returns
this

setMaxPitch(pitch, options?)

Sets the maximum map pitch.

Parameters

pitch

number

The desired maximum pitch in degrees.

options?

Options for animating the pitch in case the current pitch is more than the new maximum.

Returns
this

setMaxZoom(zoom, options?)

Sets the maximum map zoom.

Parameters

zoom

number

The desired maximum zoom.

options?

Options for adjusting map zoom in case the current zoom is more than the new maximum.

Returns
this

setMinPitch(pitch, options?)

Sets the minimum map pitch.

Parameters

pitch

number

The desired minimum pitch in degrees.

options?

Options for animating the pitch in case the current pitch is less than the new minimum.

Returns
this

setMinZoom(zoom, options?)

Sets the minimum map zoom.

Parameters

zoom

number

The desired minimum zoom.

options?

Options for adjusting map zoom in case the current zoom is less than the new minimum.

Returns
this

setOption(option, value)

Sets a new value for the map option.

Parameters

option

T

Map option name. Only 'disableDragging', 'enableTrackResize', 'loopWorld', 'disableHidingPois', or 'enableTwoFingerDragging' options are available.

value

NonNullable<MapOptions[T]>

New value of the map option.

Returns
this

setPadding(padding, options?)

Sets the map padding. The padding on each side has a clamp to a positive value no larger than the map canvas size for either side

Parameters

padding

Partial<Padding>

Padding in pixels from the different sides of the map canvas

options?

Padding animation options.

Returns
this

setPitch(pitch, options?)

Sets the map pitch angle.

Parameters

pitch

number

The desired map pitch in degrees.

options?

Pitch animation options.

Returns
this

setRotation(rotation, options?)

Sets the map rotation angle.

Parameters

rotation

number

The desired map rotation in degrees.

options?

Rotation animation options.

Returns
this

setSelectedObjects(ids, scope?)

Selects objects on the map by identifiers.

Parameters

ids

string[]

An array of identifiers of objects that should be selected.

scope?

string

The scope of the identifiers. If not specified default scope is used.

Returns
this

setStyleById(styleId)

Uploads styles object by its id and applies it to the map. Returns a promise that contains param styleId.

Parameters

styleId

string

uuid of the style.

Returns
Promise<string>

setStyleFromUrl(styleUrl, options)

Experimental method. Uploads styles object from URL and applies it to the map. Returns a promise that contains param styleId.

Warning: Setting a style this way might result in an incompatible style being applied. Map styles are constantly evolving in order to display new cartographic data. By storing the style on your own side, you assume the responsibility to update it periodically and take care of its relevance.

Use it only if you know that the style at this url is compatible with your version of mapgl. In other cases it is recommended to use setStyleById to set a style from the Style Editor.

Parameters

styleUrl

string

Base URL of the style. It is used to resolve paths provided in the options.

options

Contains paths to styles, icons, fonts, models etc

Returns
Promise<string>

setStyleState(styleState)

Sets whole map style global variables at once, any previously set variables will be reset or overridden.

Parameters

styleState

Returns
this

setStyleZoom(styleZoom, options?)

Sets the map style zoom.

Parameters

styleZoom

number

The desired style zoom.

options?

Zoom animation options.

Returns
this

setZoom(zoom, options?)

Sets the map zoom.

Parameters

zoom

number

The desired zoom.

options?

Zoom animation options.

Returns
this

showLayers(params)

Shows the layer or all layers in a group in the current map style and updates the active layers. If only the id is specified, the corresponding layer or group will be shown. If only the type is specified, all layers with this type will be shown. If both the layer type and id are specified, layers will be shown by type, and the id will be ignored.

Parameters

params

Returns
this

showTraffic

Shows the traffic layer on the map.

Returns
this

triggerRerender

Calls the map rerender.

Returns
void

unproject(point)

Returns geographical coordinates [longitude, latitude] that correspond to the specified pixel coordinates.

Parameters

point

number[]

The pixel coordinates [x, y] of the map's container to unproject.

Returns
number[]

Marker

Class for creating markers on the map.

Extends: Evented<DynamicObjectEventTable<Marker>>

new constructor(map, options)

Example:

const marker = new mapgl.Marker(map, {
coordinates: map.getCenter()
});
Parameters

map

Map<>

The map instance.

options

Marker options.

Returns
Marker<>
Methods

destroy

Destroys the marker.

Returns
void

emit(type, data?)

Calls all event listeners with event type type

Parameters

type

K

Event type

data?

DynamicObjectEventTable<Marker>[K]

Data transferred to events

Returns
this

getCoordinates

Returns current marker center in geographical coordinates [longitude, latitude] .

Returns
number[]

getRotation

Returns a clockwise rotation angle of the marker icon in degrees.

Returns
number

hide

Hides the marker.

Returns
this

off(type, listener)

Removes event listener registered with on

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Marker>[K]) => void

Event handler

Returns
this

on(type, listener)

Registers event listener

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Marker>[K]) => void

Event handler

Returns
this

once(type, listener)

Registers event listener which will be called once

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Marker>[K]) => void

Event handler

Returns
this

setCoordinates(coordinates)

Sets the geographical center of the marker.

Parameters

coordinates

number[]

Coordinates [longitude, latitude] where the center of the marker should be set.

Returns
this

setHoverIcon(iconOptions?)

Sets the hover icon of the marker. If you pass empty options, the current hover just will be deleted.

Parameters

iconOptions?

Options include icon URL, optional anchor and size.

Returns
this

setIcon(iconOptions)

Sets the icon of the marker.

Parameters

iconOptions

Options include icon URL, optional anchor and size.

Returns
this

setLabel(labelOptions?)

Sets the label of the marker. If you pass an empty label, the current one just will be deleted.

Parameters

labelOptions?

Options of a new marker label.

Returns
this

setRotation(angle)

Sets the clockwise rotation of the icon.

Parameters

angle

number

Angle in degrees.

Returns
this

show

Displays hidden marker.

Returns
this

Polygon

Class for creating a polygon on the map

Extends: Evented<DynamicObjectEventTable<Polygon>>

new constructor(map, options)

Example:

const polygon = new mapgl.Polygon(map, {
coordinates: [
[
[82.878543, 54.975937],
[82.903049, 54.981333],
[82.929373, 54.973391],
[82.902421, 54.996199],
[82.878543, 54.975937],
],
[
[82.908136, 54.987526],
[82.899028, 54.983494],
[82.897673, 54.988904],
[82.908136, 54.987526],
],
],
color: '#990000',
strokeColor: '#bb0000',
});
Parameters

map

Map<>

The map instance

options

Polygon options

Returns
Polygon<>
Methods

destroy

Destroys the polygon

Returns
void

emit(type, data?)

Calls all event listeners with event type type

Parameters

type

K

Event type

data?

DynamicObjectEventTable<Polygon>[K]

Data transferred to events

Returns
this

off(type, listener)

Removes event listener registered with on

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Polygon>[K]) => void

Event handler

Returns
this

on(type, listener)

Registers event listener

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Polygon>[K]) => void

Event handler

Returns
this

once(type, listener)

Registers event listener which will be called once

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Polygon>[K]) => void

Event handler

Returns
this

Polyline

Class for creating a polyline on the map

Extends: Evented<DynamicObjectEventTable<Polyline>>

new constructor(map, options)

Example:

const polyline = new mapgl.Polyline(map, {
coordinates: [
[82.878543, 54.975937],
[82.903049, 54.981333],
[82.929373, 54.973391],
],
});
Parameters

map

Map<>

The map instance

options

Polyline options

Returns
Polyline<>
Methods

destroy

Destroys the polyline

Returns
void

emit(type, data?)

Calls all event listeners with event type type

Parameters

type

K

Event type

data?

DynamicObjectEventTable<Polyline>[K]

Data transferred to events

Returns
this

off(type, listener)

Removes event listener registered with on

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Polyline>[K]) => void

Event handler

Returns
this

on(type, listener)

Registers event listener

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Polyline>[K]) => void

Event handler

Returns
this

once(type, listener)

Registers event listener which will be called once

Parameters

type

K

Event type

listener

(ev: DynamicObjectEventTable<Polyline>[K]) => void

Event handler

Returns
this

Raster

Class for creating a raster on the map.

new constructor(map, options)

Example:

const raster = new mapgl.Raster(map, {
bounds: map.getBounds(),
image: {
url: 'some/url'
},
});
Parameters

map

Map<>

The map instance.

options

Raster options.

Returns
Raster<>
Methods

destroy

Destroys the raster.

Returns
void

updateImage(options)

Updates an image URL or size of the raster on the map.

Parameters

options

Options that include a URL or geographical bounds.

Returns
Promise<void>

RasterTileSource

Class for creating raster tile source on the map

new constructor(map, options)

Example:

const source = new RasterTileSource(map, {
url: (x, y, zoom) => `https://tile.openstreetmap.org/${zoom}/${x}/${y}.png`,
attributes: { foo: 'asd' },
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
});
Parameters

map

Map<>

The map instance

options

Spatial data source options

Returns
RasterTileSource<>
Methods

destroy

Destroys the source

Returns
void

getAttributes

Get the source attributes

setAttributes(attributes)

Set the source attributes

Parameters

attributes

Returns
this

ScaleControl

A control that shows the scale line for the current map state. It appears on the map only if you set the scaleControl option within

Extends: Control

new constructor(map, options?)

Example:

const control = new mapgl.ScaleControl(
map,
{ position: 'topRight' },
);
Parameters

map

Map<>

The map instance.

options?

Control options.

Returns
ScaleControl<>
Methods

destroy

Destroys the scale control.

Returns
void

getContainer

Returns the container of the control.

Returns
HTMLDivElement<>

getPosition

Returns the position of the control.

setPosition(position)

Sets the position of the control.

Parameters

position

Required position of the control.

Returns
void

TrafficControl

A control for enabling a traffic layer on the map. It appears on the map only if you set the trafficControl option within

Extends: Control

new constructor(map, options?)

Example:

const control = new mapgl.TrafficControl(
map,
{ position: 'topRight' },
);
Parameters

map

Map<>

The map instance.

options?

Control options.

Returns
TrafficControl<>
Methods

destroy

Destroys the control.

Returns
void

getContainer

Returns the container of the control.

Returns
HTMLDivElement<>

getPosition

Returns the position of the control.

setPosition(position)

Sets the position of the control.

Parameters

position

Required position of the control.

Returns
void

ZenithSource

Class representing Zenith data source.

new constructor(map, options)

Example:

const customZenithSource = new mapgl._J.ZenithSource(map, {
tileTemplateUrl: `${mapgl._J.ZenithSource.tileTemplateUrl}&user_layer_id=${id}`
metatileTemplateUrl: `mapgl._J.ZenithSource.metatileTemplateUrl`
appId: map.state.appId,
tileServer: map.state.tileServer,
tileSet: map.state.tileSet,
tileProtocol: map.state.tileProtocol,
tileKey: map.state.tileKey,
subdomains: map.state.subdomains,
sourceAttributes: {
sourceName: 'zenith-custom-source',
}
});

map.setStyle({
// ...
layers: [
// ...
filter: [
'all',
['match', ['sourceAttr', 'sourceName'], ['zenith-custom-source'], true, false]
// ...
]
]
})
Parameters

map

Map<>

The map instance

options

Zenith source options

Returns
ZenithSource<>
Methods

destroy

Destroys the source

Returns
void

getAttributes

Gets the source attributes

setAttributes(attributes)

Sets the source attributes

Parameters

attributes

Returns
this

setFeatureStateMap(featureStateMap)

Sets the feature state map to the source.

See DefaultSource.setFeatureStateMap

Parameters

featureStateMap

Returns
void

ZoomControl

A basic control with two buttons for zooming in and out. It is added to the map by default unless you set its zoomControl option to false .

Extends: Control

new constructor(map, options?)

Example:

const control = new mapgl.ZoomControl(
map,
{ position: 'topRight' },
);
Parameters

map

Map<>

The map instance.

options?

Control options.

Returns
ZoomControl<>
Methods

destroy

Destroys the zoom control.

Returns
void

getContainer

Returns the container of the control.

Returns
HTMLDivElement<>

getPosition

Returns the position of the control.

setPosition(position)

Sets the position of the control.

Parameters

position

Required position of the control.

Returns
void