Labels

DG.Label

DG.Label class implements a small hint which may appear over a particular object on the map (above a marker or a vector layer, for example). Also, the tips can be shown not only when you hover the mouse over the object, but constantly, these tips are called static.

Example of usage

To enable the display of tips when you hover over the marker is quite easy:

DG.marker([54.9502, 82.8380], {
    label : 'I'm a tip!'
}).addTo(map);

For vector layers, you can specify a tip in this way, for example:

DG.polyline([
    [55.02, 83.02],
    [54.97, 83.03],
    [54.95, 83.01],
    [54.98, 82.97]
], {
    label: 'I am a hint!'
}).addTo(map);

To add a tip to an object that has been already created, you can call the bindLabel method:

var marker = DG.marker([54.9502, 82.8980]).addTo(map);
marker.bindLabel('I am a static tip!', { static: true });

Options

When you call the bindLabel method, you can set the following options for the tooltip:

Option Type Default Description
offset Point Point(12, 15) The offset of a tooltip container relative to the cursor position (the position of the marker in the case when used with a marker).
className String 'dg-label' The CSS class that will be assigned to the DOM element of the tooltip.
static Boolean false If the value is set to true, then the tooltip will be always visible (this option is available only for a marker tip).