Controls | RasterJS API | 2GIS Documentation
RasterJS API

Controls

Controls is a user interface components by which a user can interact with the map.

A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its zoomControl option to false. Extends Control.

Creation

Factory Description
DG.control.zoom( <DG.Control.Zoom options> options ) Creates a zoom control

Options

Option Type Default Description
zoomInText String '+' The text set on the 'zoom in' button.
zoomInTitle String 'Zoom in' The title set on the 'zoom in' button.
zoomOutText String '-' The text set on the 'zoom out' button.
zoomOutTitle String 'Zoom out' The title set on the 'zoom out' button.

Options inherited from Control

Methods

Methods inherited from Control

The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its attributionControl option to false, and it fetches attribution texts from layers with the getAttribution method automatically. Extends DG.Control.

Creation

Factory Description
DG.control.attribution( <DG.Control.Attribution options> options ) Creates an attribution control.

Options

Option Type Default Description
prefix String 'Leaflet' The HTML text shown before the attributions. Pass false to disable.

Options inherited from Control

Methods

Method Returns Description
setPrefix( <String> prefix ) this Sets the text before the attributions.
addAttribution( <String> text ) this Adds an attribution text (e.g. 'Vector data &copy; Mapbox').
removeAttribution( <String> text ) this Removes an attribution text.

Methods inherited from Control

A simple scale control that shows the scale of the current center of screen in metric (m/km) and imperial (mi/ft) systems. Extends DG.Control.

DG.control.scale().addTo(map);

Creation

Factory Description
DG.control.scale( <DG.Control.Scale options> options? ) Creates an scale control with the given options.

Options

Option Type Default Description
maxWidth Number 100 Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500).
metric Boolean True Whether to show the metric scale line (m/km).
imperial Boolean True Whether to show the imperial scale line (mi/ft).
updateWhenIdle Boolean false If true, the control is updated on moveend, otherwise it's always up-to-date (updated on move).

Options inherited from Control

Methods

Methods inherited from Control

When clicked opens a ruler - the tool for measurement of distances on a map. Extends DG.Control.

DG.control.ruler().addTo(map);

Creation

Factory Description
DG.control.ruler( <DG.Control.Ruler options> options? ) Creates a ruler control with the given options.

Options

Options inherited from Control

Methods

Methods inherited from Control

The traffic control allows you to display traffic overlay data on a map. Extends DG.Control.

DG.control.traffic().addTo(map);

Creation

Factory Description
DG.control.traffic( <DG.Control.Traffic options> options? ) Creates a traffic control with the given options.

Options

Options inherited from Control

Methods

Methods inherited from Control

The fullscreen control enables display of the map over fullscreen window which bounds are physical bounds of a given user monitor. The button works like a trigger. It is put on the map by default unless you set its fullscreenControl option to false. Extends DG.Control.

DG.control.fullscreen().addTo(map);

Creation

Factory Description
DG.control.fullscreen( <DG.Control.Fullscreen options> options? ) Creates a fullscreen control with the given options.

Options

Options inherited from Control

Methods

Methods inherited from Control

The geo-location control allow users to detect their geographic positions and automatically pan the map layer to found coordinates. Control is disabled if geo-location API is not available.

DG.control.location().addTo(map);

Creation

Factory Description
DG.control.location( <DG.Control.LocationControl options> options? ) Creates a geo-location control with the given options.

Options

Option Type Default Description
drawCircle Boolean true Will the circle showing the accuracy of the detection be displayed or not.
follow Boolean false Update user location dynamically or not, works if watch and setView options are exposed to true in locateOptions.
stopFollowingOnDrag Boolean false Enables or disables the user's location update as he drag the map.
metric Boolean true Use metric or English units of measurement.
locateOptions Object See geo-location options.

Options inherited from Control

Methods

Methods inherited from Control