interface
AnimationOptions
Common options for map animations. Used by methods such as setCenter, setZoom, etc.
ArrowOptions
Arrow initialization options.
animate?
Whether to animate the arrow.
false
by default.
color?
Fill color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
coordinates
Arrow path or an array of arrow paths.
Simple case — a single arrow (
number[][]
):
An array of points
[firstPoint, secondPoint, ...]
,
where each point is a geographical coordinate
[longitude, latitude]
.
General case — multiple arrows (
number[][][]
):
An array of paths
[firstArrowPath, secondArrowPath, ...]
,
where each path is an array of points
[firstPoint, secondPoint, ...]
,
and each point is a geographical coordinate
[longitude, latitude]
.
Each path defines a single arrow drawn along it with an arrow tip at the end. Multiple paths can be provided to draw several arrows within one Arrow object.
interactive?
Whether the arrow responds to pointer events.
true
by default.
iterationCount?
Number of animation iterations.
Set to
1
for a single animation or a higher number for repeated animations.
Note: This option takes effect only when
animate
is
true
.
maxZoom?
Maximum display styleZoom.
minZoom?
Minimum display styleZoom.
roundingRadius?
The rounding radius of arrow corners in pixels. Should correspond the width value.
strokeColor?
Stroke color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
strokeWidth?
Stroke width in pixels.
tipHeightMultiplier?
The height multiplier of the arrow tip.
tipMovementAmplitude?
The amplitude of the tip movement during animation in pixels.
tipWidthMultiplier?
The width multiplier of the arrow tip.
userData?
User specific data.
width?
Line width in pixels.
zIndex?
Draw order.
BinaryFeatureStateMap
Binary representation of featureStateMap. Contains usual FeatureStateMap data packed by @2gis/json2pbf library
Example:
import { packJson } from '@2gis/json2pbf';
const featureStateMap = {
"70030076195691401": { "height": 300 },
"70030076130722099": { "height": 200 },
}
const packed = packJson(featureStateMap);
ChangeLanguageEvent
Contains current map language
lang
Language short name.
CircleMarkerOptions
CircleMarker initialization options.
color?
Fill color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
coordinates
Geographical coordinates of the circleMarker center and optional height in meters :
[longitude, latitude, height?]
.
diameter?
CircleMarker diameter in pixels.
interactive?
Allows the circleMarker to emit events (like
mouseover
).
true
by default.
maxZoom?
Maximum display styleZoom.
minZoom?
Minimum display styleZoom.
stroke2Color?
The second stroke color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
[DEPRECATED] Will be removed in the next major release, use additional CircleMarker to draw an extra stroke.
stroke2Width?
The second stroke width in pixels.
[DEPRECATED] Will be removed in the next major release, use additional CircleMarker to draw an extra stroke.
strokeColor?
Stroke color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
strokeWidth?
Stroke width in pixels.
userData?
User defined data
zIndex?
Draw order.
CircleOptions
Circle initialization options.
color?
Fill color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
coordinates
Geographical coordinates of the circle center:
[longitude, latitude]
.
interactive?
Allows the circle to emit events (like
mouseover
).
true
by default.
maxZoom?
Maximum display styleZoom.
minZoom?
Minimum display styleZoom.
radius
Circle radius in meters.
strokeColor?
Stroke color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
strokeWidth?
Stroke width in pixels.
userData?
User specific data.
zIndex?
Draw order.
ControlOptions
Control initialization options.
position?
Position of the control.
By default it's
topRight
.
DashedLineStyleLayer
Dashed line style layer.
DefaultEventTargetData
The default targetData of a pointer event.
floorId?
ID of the particular floor. It's specified when the target object is a part of a floor plan object (e.g. the room in a building).
id
ID of the target object.
layerId?
Style layer ID of the target object.
poiIcon?
POI icon data. It's specified when the target object is a POI with an icon.
type
Type the default event data.
DestroyMapEvent
Destroy event.
DynamicObjectEventTable
The list of events that can be emitted by markers.
click
Emitted when the marker is clicked.
mousedown
Emitted when the user presses a mouse button over the marker.
mousemove
Emitted when the user moves the pointer over the marker.
mouseout
Emitted when the user moves the mouse away from the marker.
mouseover
Emitted when the user hovers over the marker.
mouseup
Emitted when the user releases the mouse button over the marker.
touchend
Emitted when the user lifts the finger off the marker.
touchmove
Emitted when the user moves the finger across the marker.
touchstart
Emitted when the user taps on the marker.
DynamicObjectPointerEvent
The event type for pointer-related map object events.
EventTarget
The target of a pointer event.
id
ID of the target object.
FeatureState
FeatureState attributes.
[key: string]
FeatureStateMap
FeatureStateMap source attributes.
Example:
const featureStateMap = {
"70030076195691401": { "height": 300 },
"70030076130722099": { "height": 200 },
}
[key: string]
FitBoundsOptions
Options for fitBounds method.
animation?
Animation options.
considerRotation?
If true the fitBounds will consider the map rotation
maxZoom?
The limit for the maximum zoom.
padding?
The amount of padding in pixels to add to the given bounds.
skipMapPadding?
If true fitBounds ignores the padding property in the map options
FloorControlOptions
Floor control initialization options.
position?
Position of the control.
By default it's
topRight
.
FloorLevel
Contains a floor level data.
FloorLevelChangeEvent
Contains a current floor level data.
FloorPlanHideEvent
Contains a disappeared floor plan data.
floorPlanId
An id of a disappeared floor plan.
FloorPlanShowEvent
Contains an appeared floor plan data.
GeoJsonEventTargetData
The GeoJson target data of a pointer event.
GeoJsonSourceOptions
GeoJson data source initialization options.
attributes?
Data source attributes.
data
GeoJSON collection of feature objects or feature object.
dimensions?
Number of coordinates per vertex in the input array (2 by default)
idScope?
Put IDs of source features to separate ID-scope. If idScope isn't specified, all IDs will be added into the default scope. Objects that have the same ID inside ID-scope will be processed by map as one object. For example, these objects will be selected simultaneously.
Scope of the identifiers is used for objects selection, see method map.setSelectedObjects.
maxZoom?
The maximum zoom value for which geojson tiles will be generated.
modelsPath?
Path to the models. Used when model's url in the source is a relative path
promoteId?
Name of the object attribute to use as ID. If specified, ID will be presented in GeoJsonEventTargetData.
tolerance?
Simplification tolerance (higher means simpler)
GeoJsonViewportSourceOptions
GeoJson viewport data source initialization options.
attributes?
Data source attributes.
data
GeoJSON source data bbox function.
dimensions?
Number of coordinates per vertex in the input array (2 by default)
idScope?
Put IDs of source features to separate ID-scope. If idScope isn't specified, all IDs will be added into the default scope. Objects that have the same ID inside ID-scope will be processed by map as one object. For example, these objects will be selected simultaneously.
Scope of the identifiers is used for objects selection, see method map.setSelectedObjects.
maxZoom?
The maximum zoom value for which geojson tiles will be generated.
modelsPath?
Path to the models. Used when model's url in the source is a relative path
promoteId?
Name of the object attribute to use as ID. If specified, ID will be presented in GeoJsonEventTargetData.
tolerance?
Simplification tolerance (higher means simpler)
viewportPadding?
Viewport padding in pixels to increase the viewport-based area to get data.
GraphicsPreset
Graphics preset.
GroupStyleLayer
Group layer.
id
Layer identifier.
layers
Array of layers that the group contains. The array must not contain other layers with the
group
type, because nested groups are not supported.
orderBy?
Defines the drawing order of objects on the map. Objects are grouped by the first expression. Within the resulting groups, they are regrouped by the next one, and so on.
type
Layer type.
HeatmapStyleLayer
Heatmap style layer.
HtmlMarkerOptions
HtmlMarker initialization options.
anchor?
The position in pixels of the "tip" of the HTML marker relative to its top-left corner.
coordinates
An array of numbers
[longitude, latitude, height?]
, where:
- 'longitude' and 'latitude' are the geographical coordinates of the top-left corner of the HTML marker. Taking into account the 'anchor' option.
- 'height' is an optional number in meters by which the marker will be raised/lowered (depending on the sign of the value) relative to the map surface. 0 by default.
disableRounding?
If true, the marker coordinates will not be rounded. By default it's
false
.
html
HTML content of the HTML marker.
interactive?
HTML marker can be pointer-event target if this option is set to
true
(pointer-events: auto),
otherwise it can't (pointer-events: none).
labeling?
HTML marker labeling options.
- type: 'none' — the marker is always visible and not involved in labeling
- type: 'full' — the marker can hide other labeling elements or can be hidden
- type: 'invincible' — the marker is always visible and can hide other labeling elements
- type: 'pinnedToPoi' — the marker can hide other labeling elements or can be hidden. It's labeling behavior is taken from the linked POI id.
- width — the width of the labeling box
- height — the height of the labeling box
- offset — the offset in pixels of the labeling box. Positive values indicate right and down, while negative values indicate left and up.
- poiId — the linked POI id
maxZoom?
Maximum display styleZoom of the HTML marker.
minZoom?
Minimum display styleZoom of the HTML marker.
preventMapInteractions?
Capture events if set. Otherwise events will passed to the map. By default it's
true
.
userData?
User specific data.
zIndex?
Draw order.
LabelImage
Source image for text label background.
padding?
Sets the space in pixels between the label text box and the edge of the stretched image for all four sides [top, right, bottom, left], like in CSS. [0, 0, 0, 0] by default.
pixelRatio?
The ratio of logical pixels in the image to physical pixels on the screen.
size
[width, height]
— image size in logical pixels
stretchX?
Defines the parts of the image that can be stretched horizontally.
stretchY?
Defines the parts of the image that can be stretched vertically.
url
Source image URL.
LabelLineStyleLayer
Label line style layer.
LabelOptions
Label initialization options.
anchor?
The offset distance of text box from its
relativeAnchor
.
Positive values indicate left and up, while negative values indicate right and down.
[DEPRECATED] Will be removed in the next major release, use the
offset
option instead.
color?
Text color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
coordinates
An array of numbers
[longitude, latitude, height?]
, where:
- 'longitude' and 'latitude' are the geographical coordinates of the top-left corner of the label.
Taking into account the
relativeAnchoroption. - 'height' is an optional number in meters by which the label will be raised/lowered (depending on the sign of the value) relative to the map surface. 0 by default.
fontSize?
Text size.
haloColor?
Background color of letters (when
haloRadius
is specified). The same format as for
color
.
haloRadius?
Use
haloRadius
to add background behind each letter.
image?
Background image for the label.
interactive?
Allows the label to emit events (like
mouseover
).
false
by default.
labeling?
Labeling options
- none — the label is not involved in the labeling process in any way
- pointLabelsOnly — the label overlaps or can be overlapped by labels having this labeling option specified as type
letterSpacing?
Space between each letter.
lineHeight?
For multiline label
lineHeight
specify how far lines between each other.
maxZoom?
Maximum display styleZoom of the label.
minZoom?
Minimum display styleZoom of the label.
offset?
The offset distance of text box from its
relativeAnchor
.
Positive values indicate right and down, while negative values indicate left and up.
relativeAnchor?
Coordinates (from 0 to 1 in each dimension) of the text box "tip" relative to its top left corner, for example:
[0, 0] value is the top left corner, [0.5, 0.5] — center point, and [1, 1] is the bottom right corner of the box.
The label will be placed so that this point is at geographical
coordinates
respects the absolute
offset
.
text
Label's text.
userData?
User specific data.
zIndex?
Draw order.
LineExtrusionStyleLayer
Line extrusion style layer.
LineStyleLayer
Line style layer.
LngLatBounds
Geographical bounds.
MapEvent
The general event type for map events.
isUser
True if event was emitted by user's interaction.
MapEventTable
The list of events that can be emitted by the map.
center
Emitted repeatedly during any change in the map's center.
centerend
Emitted after any change in the map's center.
centerstart
Emitted before any change in the map's center.
changeLanguage
Emitted after the map language is changed.
click
Emitted when the map is clicked.
contextmenu
Emitted when the map is clicked by right button.
destroy
Emitted after the map is destroyed.
floorlevelchange
Emitted after the floor plan level is changed.
floorplanhide
Emitted after the floor plan is disappeared from the map.
floorplanshow
Emitted after the floor plan is shown on the map.
idle
Emitted when the map becomes idle after some interaction (drag, zoom etc). Idle means that the map is not interacting, all tiles are drawn and labeling is finished. This event doesn't take into account any asset loading (for example, marker icons).
mousedown
Emitted when the user presses a mouse button over the map.
mousemove
Emitted when the user moves the pointer over the map.
mouseout
Emitted when the user moves the mouse away from the map item.
mouseover
Emitted when the user hovers over a map item.
mouseup
Emitted when the user releases the mouse button over the map.
move
Emitted repeatedly during any transition from one map view to another, caused by moving, zooming, rotating, or pitching.
moveend
Emitted after any transition from one map view to another, caused by moving, zooming, rotating, or pitching.
movestart
Emitted before any transition from one map view to another, caused by moving, zooming, rotating, or pitching.
pitch
Emitted repeatedly during any change in the map's pitch.
pitchend
Emitted after any change in the map's pitch.
pitchstart
Emitted before any change in the map's pitch.
resize
Emitted after any change in the map's size.
rotation
Emitted repeatedly during any change in the map's pitch.
rotationend
Emitted after any change in the map's pitch.
rotationstart
Emitted before any change in the map's pitch.
styleload
Emitted after the map style is loaded.
styleloaderror
Emitted after the map style fails to load.
touchend
Emitted when the user lifts the finger off the map.
touchmove
Emitted when the user moves the finger across the map.
touchstart
Emitted when the user taps on the map.
traffichide
Emitted after the traffic layer hid from the map.
trafficscore
Emitted after update current traffic score.
trafficshow
Emitted before the traffic layer showed on the map.
zoom
Emitted repeatedly during any change in zoom level.
zoomend
Emitted after any change in zoom level.
zoomstart
Emitted before any change in zoom level.
MapOptions
Map initialization options.
autoHideOSMCopyright?
Enables OSM copyright auto hide after 5 sec
[DEPRECATED] This option is no longer supported and will be removed in the next major release.
center?
Map center in geographical coordinates (
[longitude, latitude]
).
controlsLayoutPadding?
Sets padding for controls layout
copyright?
Where to add copyright control during the map initialization. By default it's
"bottomRight"
.
defaultBackgroundColor?
Sets default background color, while style is loading
disableAntiAliasing?
Disables fullscreen AntiAliasing when map is idle. True by default.
disableDragging?
Prevents the map from dragging.
disableHidingPois?
Disables hiding POIs behind objects such as buildings, 3D models, etc. False by default.
disablePitchByUserInteraction?
Prevents users from pitching the map.
disableRenderingCache?
Disable render caching.
disableRotationByUserInteraction?
Prevents users from rotating the map.
disableZoomOnScroll?
Disables map zoom on scrolling over the map container.
enableTrackResize?
Tracks changes of the map container size and automatically updates the size of the map.
enableTwoFingerDragging?
Enables map dragging using two touches.
If set to true, three touches will pitch map.
Single touch drag will be enabled also, use
disableDragging: true
to disable it.
floorControl?
Whether a floor control should be added during the map initialization. By default it's
false
.
Set to
true
to add the floor control at
"topRight"
position.
forceSyncIdentify?
Forces map to use syncronous objects picking (identification). This can cause performance issues on some devices, but can fix artifacts when sharing gl-context between different libraries (e.g. deck.gl).
graphicsPreset?
Sets active graphics preset.
If set map will work in graphics preset mode:
- map takes into an account configured graphics presets in style
- map.getGraphicsPreset() method becomes available
Otherwise, map will ignore graphics presets from style object.
Available values:
- 'light' - light graphics preset
- 'normal' - normal graphics preset
- 'immersive' - immersive graphics preset
- 'auto' - EXPERIMENTAL graphics preset will be set depending on benchmark result
iconIdentifyOpacity?
When rendering icons to the identification scene, pixels with opacity below this value will be ignored. Default value is 0.3.
keepCenterWhileUserZoomRotate?
Prevents center changing while user is zooming or rotating the map by touch.
key?
The key that allows usage of the API.
lang?
The desired map language. short language code 'en', 'ru', ...etc
loopWorld?
Loop the map when rendering at large scales or near the anti-meridian
lowZoomMaxPitch?
Maximum map pitch in degrees for low zoom (zoom < 16.5).
maxBounds?
The map will be constrained to the given bounds, if set.
maxPitch?
Maximum map pitch in degrees.
maxZoom?
Maximum map styleZoom.
minPitch?
Minimum map pitch in degrees.
minZoom?
Minimum map styleZoom.
padding?
Dimensions in pixels applied on each side of the viewport for shifting the vanishing point. the padding on each side has a clamp to a positive value no larger than the map canvas size for either side
pitch?
Map pitch in degrees.
preserveDrawingBuffer?
Sets preserveDrawingBuffer option to WebGLRenderingContext.
rotation?
Map rotation in degrees.
scaleControl?
Whether a scale control should be added during the map initialization. By default it's
false
.
Set to
true
to add the scale control at
"bottomLeft"
position.
style?
The map style ID, that you can get at https://styles.2gis.com
styleOptions?
Map style options. Containts path to style assets - icons, fonts, models etc. Warning: If the options are incompatible, a broken style might be 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. It is recommended to use map.setStyleById to update styles during runtime.
styleState?
Map style global variables
styleZoom?
Map style zoom. Use this option if you want to set the same zoom that is used in the style settings. The styleZoom and zoom options set the same map scale but in different projections. If both options are set, the styleZoom has a higher priority than the zoom option.
touchRotationThreshold?
Map rotation threshold with multitouch in degrees. 10 by default.
trafficControl?
Whether a traffic control should be added during the map initialization. By default it's
false
.
Set to
true
to add the traffic control at
"topRight"
position.
trafficOn?
Whether traffic layer is enabled on the map.
useRtlTextPlugin?
Enables map to download additional plugin for RTL-text rendering. Values are:
- 'always-on' - plugin will be downloaded at map initialization.
- 'always-off - plugin will not be downloaded.
- 'depends-on-language' - plugin will be downloaded only if "ar" language is selected.
Default value is 'depends-on-language'. If the language of the map is not rtl (eg. 'en') and tiles contain rtl labels, you should use 'always-on' to render rtl label properly.
webglVersion?
Sets the map WebGL version. It can be helpful if you use CustomLayer with other WebGL libraries.
zoom?
Map zoom.
zoomControl?
Whether a zoom control should be added during the map initialization. By default it's
"topRight"
.
Set to
false
to not add the control.
MapPointerEvent
The event type for pointer-related map events.
MapSupportOptions
Options for Map.isSupported method.
failIfMajorPerformanceCaveat
Causes isSupported method to return false if the performance of MapGL would be dramatically worse than expected (i.e. a software renderer is would be used)
MarkerIconOptions
Options for marker setIcon and setHoverIcon methods.
anchor?
The position in pixels of the "tip" of the icon (relative to its top left corner). The icon will be aligned so that this point is at the marker's geographical location. Centered by default if size is specified.
icon
Marker icon URL.
opacity?
Marker icon opacity.
size?
Marker icon size
[width, height]
in pixels.
MarkerLabelOptions
Options for the label of marker.
anchor?
The offset distance of text box from its
relativeAnchor
.
Positive values indicate left and up, while negative values indicate right and down.
[DEPRECATED] Will be removed in the next major release, use the
offset
option instead.
color?
Text color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
font?
Font family.
fontSize?
Text size.
haloColor?
Background color of letters (when
haloRadius
is specified). The same format as for
color
.
haloRadius?
Use
haloRadius
to add background behind each letter.
image?
Background image for the label.
letterSpacing?
Space between each letter.
lineHeight?
For multiline label
lineHeight
specify how far lines between each other.
maxZoom?
Maximum display styleZoom of the label. Note that the label's zoom-dependent visibility is constrained by the marker's minZoom and maxZoom options, if specified.
minZoom?
Minimum display styleZoom of the label. Note that the label's zoom-dependent visibility is constrained by the marker's minZoom and maxZoom options, if specified.
offset?
The offset distance of text box from its
relativeAnchor
.
Positive values indicate right and down, while negative values indicate left and up.
relativeAnchor?
Coordinates (from 0 to 1 in each dimension) of the text box "tip" relative to its top left corner, for example:
[0, 0] value is the top left corner, [0.5, 0.5] — center point, and [1, 1] is the bottom right corner of the box.
The label will be placed so that this point is at geographical
coordinates
respects the absolute
offset
.
text
Label's text.
zIndex?
Draw order.
MarkerOptions
Marker initialization options.
anchor?
The position in pixels of the "tip" of the icon (relative to its top left corner). The icon will be aligned so that this point is at the marker's geographical location. Centered by default if size is specified.
coordinates
Geographical coordinates of marker center
[longitude, latitude, altitude?]
,
where altitude is an optional component in meters.
hoverAnchor?
Icon anchor in hovered state.
hoverIcon?
Marker icon URL in hovered state.
hoverOpacity?
Marker icon opacity in hovered state.
hoverSize?
Marker icon size
[width, height]
in pixels in hovered state.
icon?
Marker icon URL.
interactive?
Allows the marker to emit events (like
mouseover
).
true
by default.
label?
Initialization options of the marker's label.
maxZoom?
Maximum display styleZoom of the marker.
minZoom?
Minimum display styleZoom of the marker.
opacity?
Marker icon opacity.
rotation?
Icon clockwise rotation in the screen plane in degrees.
size?
Marker icon size
[width, height]
in pixels.
userData?
User specific data.
zIndex?
Draw order.
MetricPointStyleLayer
Metric point style layer.
ModelStyleLayer
Model style layer.
Padding
Padding in pixels on different sides of the container.
ParticleAffectorOptionsBase
Fields common to every affector config.
enabled?
Enables the affector.
false
temporarily switches it off without removing
it from the system.
true
by default.
ParticleAnchorObject
Map object that can be used as an anchor for a particle system.
Only public methods are used:
getCoordinates()
returns
[lng, lat]
or
[lng, lat, altitude(m)]
;
getRotation()
returns the rotation angle (a number, yaw in degrees) or
Euler angles
[x, y, z]
in degrees. Optional: without it rotation is ignored.
GltfModel
and
Marker
satisfy this contract.
ParticleAppearance
Appearance envelopes applied to every particle over its normalized lifetime.
This is where a particle stops being a physics body and starts being a visual: the values here are written directly into the render channels (size, rotation, color) instead of affecting velocity. Affectors, on the other hand, act on the motion — that split is why this list is not a part of the affector set.
Every channel is optional: an omitted one leaves the spawn value in place. A constant instead of an array of keys means a value that doesn't change over the lifetime.
t = age / maxAge
, so the curves are independent of
rate
,
maxParticles
and of how long the system lives — the same config scales to any lifetime.
@example [object Object]
angle?
Sprite rotation over the lifetime, in radians. Sets the absolute angle, not
the angular velocity — a spin is just a linear curve from
0
to
2 * PI * n
.
0
at every
t
(no rotation) by default.
color?
Color over the lifetime (RGBA components or a CSS string). Overwrites the spawn color completely.
scale?
Size multiplier over the lifetime, applied to the per-particle initial size ( ParticleSpawnOptions.size ) — so the random spread of sizes survives the curve and particles don't all become identical.
1
at every
t
(no change) by default.
ParticleAppearancePatch
Appearance patch:
null
removes a channel,
undefined
leaves it as is.
ParticleAppearance
describes what exists; a patch describes what to
change. Without
null
the two intents look identical: a dynamically
assembled patch with
{ color: undefined }
means both "leave it alone" and
"erase it" — and the second one is almost never intended.
A removed channel stops being applied from the next frame. Alive particles keep the last value it produced until they die — only the particles spawned afterwards get the spawn values back.
The same rule applies to
texture
:
null
goes back to procedural rendering,
undefined
is untouched.
ParticleBoxShapeOptions
Particles are born uniformly inside a box, in meters.
ParticleBuoyancyAffectorOptions
Buoyancy: pushes particles up.
value
is either a constant acceleration or a curve over the particle
lifetime — a number or an array of keys, told apart by the shape of the
value. Combine it
with
gravity
to get net lift (
gravity: -9.8
+
buoyancy: 11
gives a slow
rise).
enabled?
Enables the affector.
false
temporarily switches it off without removing
it from the system.
true
by default.
value?
Upward acceleration in m/s^2: either a constant or a curve over the
normalized lifetime.
9.81
by default.
A broken or empty key set turns the lift off (
0
) rather than falling back
to Earth's compensation: "no curve given" here means "no force given".
@example [object Object] @example [object Object]
ParticleCircleShapeOptions
Particles are born on a circle of
radius
, in meters.
ParticleCurveKey
Curve key: a value at a normalized particle lifetime.
The value type depends on the curve: a
number
for scalar curves, a
ParticleColor for color curves.
ParticleDragAffectorOptions
Medium resistance: slows particles down.
ParticleEmitterOptions
Emitter configuration — a birth volume with its own particle pool.
A system may hold several emitters: they share the anchor and the affector set (one wind for fire and smoke) and differ in everything else — shape, spawn ranges, appearance, texture and pool size.
The emitter defines only where and how particles are born. Its position is not a part of the config: it comes from the anchor ( ParticleSystemOptions.anchor ) plus ParticleEmitterOptions.offset .
@example [object Object]
appearance?
Size, colour and spin angle envelopes over the particle's lifetime.
launch?
Direction, cone, speed and inherited motion of the jet.
maxParticles
Maximum number of simultaneously alive particles — the pool size.
Required: this is the fill-rate budget, and the right value depends on the device. The engine falls back to 10 000, which is already a lot for a mobile WebView.
The pool and the GPU buffers are allocated for it, so the value is fixed for the whole lifetime of the emitter: changing it means creating a new emitter, which drops the alive particles.
offset?
Emitter offset from the system anchor,
[x, y, z]
in meters.
For an object anchor the offset is rotated together with the object and the
shape, so it stays glued to the model. The shift is applied at spawn only:
changing it does not drag the already born particles.
[0, 0, 0]
by default.
rate
Spawn rate, in particles per second.
Required: a system created without it silently spawns nothing, and that is
almost always a forgotten field rather than a deliberate choice. The
engine default is
0
, so the value can be turned up at runtime.
refraction?
Screen-space refraction of the scene for the particles of this emitter.
renderMode?
How each particle is drawn.
'billboard'
by default.
shape?
Where new particles appear. Defaults to a single point.
softness?
Edge softness of a sprite,
0
(sharp) to
1
(maximally blurred).
Implemented as a Gaussian falloff plus noise, so intermediate values
change the profile continuously.
0
by default.
spawn?
Per-particle random ranges applied at spawn.
lifetime
,
size
and
color
are required there;
mass
falls back to its
default. Omitting the whole field is allowed — the engine then uses one
second and one metre, which produces a visible but obviously generic
particle rather than an invisible one.
texture?
Texture atlas: a grid of
cols
x
rows
frames, each particle gets a random
one. Without a texture particles are rendered procedurally: a soft disc for
'billboard'
, a streak for
'stretch'
.
ParticleEmitterPatch
Partial emitter config for
ParticleSystem.patchEmitter
.
Omitted fields keep their current values. The merge rules are uniform:
top-level objects (
spawn
,
launch
,
appearance
) are merged field by
field, arrays and scalars are replaced. That is why spreading the current
resolved config is always a correct way to change a single value.
maxParticles
is deliberately absent: the pool capacity is structural — the
GPU buffers are allocated for it. Changing it means replacing the emitter:
removeEmitter
+
addEmitter
, which drops the alive particles.
appearance?
Envelopes, merged per channel:
{ scale }
keeps the color and the angle,
{ color: null }
removes the color envelope.
launch?
Partial launch settings:
direction
,
spread
,
speed
,
inheritVelocity
.
offset?
Emitter offset from the anchor, in meters.
rate?
Spawn rate, in particles per second.
refraction?
Refraction parameters,
null
to go back to plain blending,
undefined
to keep the current value.
renderMode?
Render mode. Unlike the other fields it is not applied in place: the GPU state is rebuilt on the next frame.
shape?
Where new particles appear. A different shape resets alive particles.
softness?
Edge softness of a sprite,
0
(sharp) to
1
(maximally blurred).
spawn?
Partial ranges; omitted fields keep their current values.
texture?
A new atlas, or
null
to fall back to procedural rendering.
ParticleGravityAffectorOptions
Constant vertical acceleration.
ParticleLaunchOptions
How new particles leave the emitter: direction, cone, speed and inherited motion.
Every term of the initial velocity lives here:
v = direction * speed + inheritVelocity * v_anchor
. Splitting them across objects keeps one formula
in two places.
Lives next to ParticleSpawnOptions rather than inside it, because the direction is a property of the jet, not of a single particle: it is one vector for the whole emitter.
direction?
Unit vector of the jet, normalized on input. A zero vector falls back to
[0, 0, 1]
(up).
[0, 0, 1]
by default.
Given in the emitter's local space and rotated together with the anchor, exactly like the birth position: an exhaust of a model turned by 90° flies along the model's own axis, not along the world vertical.
Multiplied by
speed
, so with
speed: 0
(the default) it has no
effect at all.
inheritVelocity?
Multiplier of the emitter's own velocity added to a newly spawned particle, so particles can trail behind, ride along or shoot ahead of a moving emitter.
0
— particles fly in world axes (smoke from a chimney);
0..1
— partially carried along (dust under wheels);
1
— particles are glued to the emitter (steam from an exhaust);
> 1
— particles overtake the emitter (a jet, splashes);
< 0
— particles fly backwards relative to the emitter (wake).
Any finite value is valid: this is a plain multiplier, not a fraction.
The full translation of the emitter is inherited: the anchor motion plus
the change of the emitter's own
offset
. Rotation is not inherited — a
particle born in place (
speed: 0
) does not orbit a turning object.
For the
'camera'
anchor the inherited velocity is the camera's own
translation, so weather effects usually keep the default: otherwise the
whole snow volume gets dragged along with the view.
0
by default.
speed?
Initial speed
[min, max]
in m/s, along
direction
.
[0, 0]
by
default: a particle is born in place and is carried away by forces.
A range: each particle gets a random value inside it. Zero here is meaningful — an effect may live entirely on wind, gravity or
inheritVelocity .
spread?
Cone half-angle around
direction
, in degrees, clamped to
0..180
.
0
makes all particles fly strictly along the direction,
180
covers the
whole sphere.
0
by default.
ParticlePointShapeOptions
All particles are born at one point — the emitter position.
type
Shape discriminant.
ParticleRefraction
Screen-space refraction parameters of an emitter.
ParticleSpawnOptions
Parameters of newly spawned particles.
Ranges are
[min, max]
: each particle gets a random value inside it.
All sizes are in meters and speeds in meters per second, regardless of the
anchor mode.
lifetime
,
size
and
color
are required. A forgotten
lifetime
or
size
produces a particle that dies in the frame it was born or is drawn at zero
size — neither is visible on the map, and there is no meaningful default for
them: the right values depend entirely on the effect.
color
is required for
the same reason: the engine default is opaque white, which on a map reads as a
rendering glitch rather than as an effect.
mass
stays optional because its default is meaningful rather than "switched
off":
mass: 1
is the neutral value all force formulas are tuned for.
The initial speed is not here — it lives in
ParticleLaunchOptions.speed , together with the direction it is applied along.
color
Initial color: RGBA components in the [0, 1] range, or a CSS string.
Required — see the note above. An alpha of
0
makes particles invisible,
which is a valid way to hide an emitter, but it has to be written explicitly.
lifetime
Lifetime
[min, max]
in seconds.
Required — see the note above.
mass?
Particle mass
[min, max]
.
[1, 1]
by default; the lower bound is clamped
so mass can never reach zero.
Mass affects the reaction to forces:
drag
,
turbulence
and
wind
are
inversely proportional to it, so lighter particles are carried away faster.
Keep it close to
1
unless the effect needs a difference between emitters:
a tiny mass freezes a particle under
drag
and snaps it to the wind speed.
size
Initial size
[min, max]
, in meters.
Required — see the note above.
ParticleSpawnPatch
Partial spawn config for
ParticleSystem.patchEmitter
.
Every field is optional: omitted ones keep their current values. This is the
patch mirror of
ParticleSpawnOptions
, where
lifetime
,
size
and
color
are required — so a patch never resends them.
color?
Initial color: RGBA components in the [0, 1] range, or a CSS string.
lifetime?
Lifetime
[min, max]
in seconds.
mass?
Particle mass
[min, max]
; the lower bound is clamped so it never reaches zero.
size?
Initial size
[min, max]
, in meters.
ParticleSphereShapeOptions
Particles are born inside a sphere of
radius
, in meters.
ParticleSystemEventTable
Events emitted by ParticleSystem .
destroy
Emitted after the system is destroyed (resources released).
reset
Emitted when ParticleSystem.reset drops all alive particles.
start
Emitted when the system resumes spawning. A new system is already spawning, so the first ParticleSystem.start emits nothing.
stop
Emitted when spawning is switched off: no new particles, alive ones live out their lifetime and fade away.
ParticleSystemOptions
Particle system options.
anchor
is required — it is the coordinate space of the system and the
reference point everything else is measured from.
emitters
is required too,
though it may be empty: a system without emitters is valid and simply draws
nothing.
const snow = new mapgl.ParticleSystem(map, {
anchor: 'camera',
emitters: {
flakes: {
renderMode: 'billboard',
rate: 5000,
maxParticles: 40000,
shape: { type: 'box', size: [400, 400, 120] },
launch: { direction: [0, 0, -1], spread: 40, speed: [4, 8] },
spawn: {
lifetime: [4, 8],
size: [0.4, 0.6],
color: [1, 1, 1, 0.85],
},
},
},
affectors: {
gravity: { type: 'gravity', value: -9.8 },
},
});
All spatial values are in meters and all speeds in meters per second, independent of the anchor mode.
affectors?
Affectors — forces acting on the particles of every emitter.
A map of
name -> config
: the key is the unique name of the affector
inside the system and is not a part of the config itself.
Affectors are applied in the order they are defined; the order of object keys is preserved. This matters for force pairs (gravity and drag do not commute), so keep the physics order in mind.
The system copies the configs on input: later mutation of the passed object has no effect.
@example [object Object]
anchor
What the emitters are bound to:
'camera'
— the system follows the camera (rain, snow);
[lng, lat, altitude?]
— a fixed geographical position (smoke, fountain);
- a map object with
getCoordinates()— particles follow the object.
No default on purpose: see ParticleAnchor .
emitters
Emitters of the system, a map of
name -> config
.
The key is the unique name of the emitter inside the system and is not a part of the config itself. Emitters are drawn in the order they are defined, which matters for transparent particles.
The anchor and the affector set are shared: they describe the world point and the forces, which several emitters of one system usually share (fire and smoke move in the same wind). Everything else — shape, spawn ranges, appearance, texture, refraction and the pool — is per emitter, so it gets a separate pool and separate GPU buffers.
userData?
User data. Never interpreted by the engine.
ParticleTextureOptions
Particle texture atlas: a grid of frames (cols by rows).
ParticleTurbulenceAffectorOptions
Turbulence — pseudo-random swirls, the most expensive affector.
Prefer a smaller
maxParticles
on weak devices.
enabled?
Enables the affector.
false
temporarily switches it off without removing
it from the system.
true
by default.
frequency?
Spatial scale of the noise field, in 1/m.
0.1
by default.
speed?
Evolution speed of the noise field, dimensionless.
0.5
by default.
strength?
Swirl intensity in m/s^2.
5
by default.
ParticleWindAffectorOptions
Wind: pushes particles towards the air velocity.
The attraction is inversely proportional to the particle mass, so light particles (snow, smoke) reach the wind speed quickly and heavy ones (raindrops) slowly.
enabled?
Enables the affector.
false
temporarily switches it off without removing
it from the system.
true
by default.
strength?
Aerodynamic drag towards the wind velocity, per axis (dimensionless, the
force is inversely proportional to mass).
[30, 30, 1]
by default: fast
horizontal drift, vertical left mostly to gravity.
velocity
Wind velocity
[x, y, z]
in m/s: X — east, Y — north, Z — up.
ParticleWrapAffectorOptions
Wraps particles inside a volume — used by weather effects to keep them near the camera.
A particle that leaves the volume re-enters from the opposite side. The volume is measured from the system anchor, not from the emitter: the emitter offset is already a part of the particle positions.
PoiIconData
The PoiIconData event type for map events.
baseUrl?
Base URL of the icon.
fullUrl?
Full URL of the icon.
fullUrlUnhovered?
Full URL of the unhovered icon.
height
Icon height.
iconMetaphorImage?
Full URL of the meta icon image.
name?
Icon name.
nameUnhovered?
Icon name of the unhovered icon.
width
Icon width.
PointerEvent
The basic event type for pointer-related events.
PointStyleLayer
Point style layer.
Polygon3dStyleLayer
3D polygon style layer.
PolygonExtrusionStyleLayer
Polygon extrusion style layer.
PolygonOptions
Polygon initialization options.
color?
Fill color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
coordinates
Geographical coordinates of polygon points in format:
[outerEdges, cropEdges1, cropEdges2, ...]
.
The first section is
outerEdges
which describes an array of outer edges:
[firstPoint, secondPoint, ..., firstPoint]
.
Each point is a geographical point:
[longitude, latitude]
. The last point should be the same as the first.
Then optionally you can crop some polygons from the main one (outer) by specifying
cropEdges1
,
cropEdges2
and so on.
A format is the same as the main section:
[firstPoint, secondPoint, ..., firstPoint]
each point is
[longitude, latitude]
.
Important:
outerEdges
and
cropEdgesN
must not touch or intersect each other.
Only the first section (
outerEdges
) is required. There may be many
cropEdges
sections.
interactive?
Allows the polygon to emit events (like
mouseover
).
true
by default.
maxZoom?
Maximum display styleZoom.
minZoom?
Minimum display styleZoom.
strokeColor?
Stroke color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
strokeWidth?
Stroke width in pixels.
userData?
User specific data.
zIndex?
Draw order.
PolygonStyleLayer
Polygon style layer.
PolylineOptions
Polyline initialization options.
color?
The line color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
color2?
The second line color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
[DEPRECATED] Will be removed in the next major release, use additional Polyline to draw an extra line with a different color.
color3?
The third line color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
[DEPRECATED] Will be removed in the next major release, use additional Polyline to draw an extra line with a different color.
coordinates
An array of polyline coordinates:
[firstPoint, secondPoint, ...]
.
Each point is a geographical point:
[longitude, latitude]
.
dashLength?
The length of the dash in pixels. If no dash length is specified, a polyline will be drawn.
gapColor?
The gap color in hexadecimal RGB (
#ff0000
) or RGBA (
#ff0000ff
) format.
gapLength?
The length of the gap in pixels. The default gap length is equal to the dash length.
hiddenPartColor?
The color of a line section that is hidden by other objects in '3d' rendering mode
in RGB hexadecimal (
#ff0000
) or RGBA (
#ff0000ff
) format.
hiddenPartGapColor?
The gap color of a line section that is hidden by other objects in '3d' rendering mode
in RGB hexadecimal (
#ff0000
) or RGBA (
#ff0000ff
) format.
interactive?
Allows the polyline to emit events (like
mouseover
).
true
by default.
maxZoom?
Maximum display styleZoom.
minZoom?
Minimum display styleZoom.
renderingMode?
Rendering mode. '2d' is default.
shift?
Line shift in pixels. Positive values indicate right and down, while negative values indicate left and up.
userData?
User specific data.
width?
The line width in pixels.
width2?
The second line width in pixels.
[DEPRECATED] Will be removed in the next major release, use additional Polyline to draw an extra line with a different width.
width3?
The third line width in pixels.
[DEPRECATED] Will be removed in the next major release, use additional Polyline to draw an extra line with a different width.
zIndex?
Draw order of the first line.
zIndex2?
Draw order of second line.
[DEPRECATED] Will be removed in the next major release, use additional Polyline to draw an extra line with a different zIndex.
zIndex3?
Draw order of third line.
[DEPRECATED] Will be removed in the next major release, use additional Polyline to draw an extra line with a different zIndex.
RasterOptions
Options for the raster.
RasterSource
Source image for the raster.
url
Url of the image for the raster.
RasterStyleLayer
Raster style layer.
RasterTileSourceOptions
RasterTileSource initialization options.
attributes?
Data source attributes.
attribution?
Contains an attribution to be displayed when the map is shown to a user.
maxZoom?
The maximum zoom value for which source data exists.
minZoom?
The minimum zoom value for which source data exists.
url
Convert tile coordinates to URL.
RotationAnimationOptions
Options for map rotation animations.
animate?
Determines if the transform should be animated.
duration?
Duration of the animation in milliseconds.
easing?
Easing function to be used with the animation.
normalize?
If enabled, the desired rotation will be normalized to (–180°; 180°], and
the direction of the rotation will be chosen so that the map makes less
than half a turn.
normalize: false
is useful for animating one of more
full turns of the map. Enabled by default.
SourceAttributes
Data source attributes.
[key: string]
Style
Stub type representing the style.
Real style types will appear a little bit later.
StyleLoadErrorEvent
Contains currently loaded error style response
style
ID or URL. Depends on the way the style was set.
StyleLoadEvent
Contains currently loaded style response
style
Style object, ID or URL. Depends on the way the style was set.
StyleOptions
Style options - paths to icons and fonts.
StyleSimpleIconConfig
Config of a simple (non-stretchable) user icon.
url
URL path to an icon:
-
absolute:
//external.domain/some_path/some_icon.svg -
template:
//{appHost}/some_path/some_icon.svg
StyleState
Style state. _activeFloorBuildingIds — an array of building IDs with active floor plans; _activeFloorIds — an array of active floor IDs from buildings with active floor plans; _activeFloorIsMetro — a flag which tells if active floors plan is a metro schema; _backgroundFloorIds — an array of background floor IDs (visible below active); _activeFloorsLevel — db_plan_level of active floor; trafficOn - a flag which tells if traffic is enabled; parkingOn - a flag which tells if parking is enabled (used in native version of 2gis); navigatorOn - a flag which tells if navigator is enabled (used in native version of 2gis); immersiveRoadsOn - a flag which tells if immersive roads are enabled; terrainEnabled - a flag which tells if 3d terrain is enabled; graphicsPreset - current graphics preset. Available values: 'light', 'normal', 'immersive'.
[key: string]
StyleStretchableIconConfig
Config of a stretchable user icon. The icon stretches to fit its content (e.g. text) while keeping the edges (like rounded corners) fixed.
height
Height of the source icon in pixels.
stretchX
Pairs of pixel ranges along the X axis that can be stretched.
For example,
[[10, 30]]
means pixels 0–10 and 30–width are fixed,
and the region 10–30 stretches.
stretchY
Pairs of pixel ranges along the Y axis that can be stretched.
For example,
[[10, 20]]
means pixels 0–10 and 20–height are fixed,
and the region 10–20 stretches.
url
URL path to an icon:
-
absolute:
//external.domain/some_path/some_icon.svg -
template:
//{appHost}/some_path/some_icon.svg
width
Width of the source icon in pixels.
TierOption
Settings for drawing an object on the surface of another map object
TrafficScoreEvent
Contains current traffic score.
score
Current traffic score
TrafficVisibilityEvent
Emitted when traffic visibility state changes
ZenithSourceOptions
Zenith data source initialization options
idScope?
Put IDs of source features to separate ID-scope. If idScope isn't specified, all IDs will be added into the "default" ID-scope. Objects that have the same ID inside ID-scope will be processed by map as one object. For example, these objects will be selected simultaneously.
Scope of the identifiers is used for objects selection, see method map.setSelectedObjects.
layerId?
ID of the layer stored on the Tile Server used to fetch tiles and other resources. "layerId" overrides the tileTemplateUrl and the metatileTemplateUrl options if they are provided,
maxZoom?
The maximum zoom level at which there will be zenith tiles of the source.
metatileTemplateUrl?
URL template used to fetch meta-tiles. If it is provided alongside the "layerId" option, "layerId" is not used.
minZoom?
The minimum zoom level at which there will be zenith tiles of the source.
promoteAttributes?
Attributes provided to the data source by every object
promoteId?
Name of the object attribute to use as id.
sourceAttributes?
Data source attributes.
tileTemplateUrl?
URL template used to fetch tiles. If it is provided alongside the "layerId" option, "layerId" is not used.
ZoomAnimationOptions
Animation options for zoom.
animate?
Determines if the transform should be animated.
duration?
Duration of the animation in milliseconds.
easing?
Easing function to be used with the animation.
useHeightForAnimation?
Intermediate zoom values will be calculated using camera's height.
- false (default): zoom values will be calculated using provided easing function.
- true: intermediate camera height calculated then converted into zoom.
Initial and final zoom values are same for both modes, only timing function changes.
true value is useful for simultaneous animation of map's center and zoom. In that case camera will fly in a straight line.
Example: map.setCenter([82.920412, 55.030111], {easing: 'easeOutCubic', duration: 800}); map.setZoom(18, {easing: 'easeOutCubic', useHeightForAnimation: true, duration: 800});