Class: Label

cercaliagl.Label


Javascript ES5

const label = new cercaliagl.Label({...});

This class is used to provide a floating overlay div HTML on Marker. This element is and DOM element, it is different than SimpleLabel which is rendered in canvas via webgl.

Example usage:

const label = new cercaliagl.Label({
  text: 'This is a label',
  className: 'cercalia-label-custom-class',
});
const marker = new cercaliagl.Marker({
  position: new cercaliagl.LonLat(1.412, 41.1),
  label: label,
});
map.addMarker(marker);

new Label(options)

Name Type Description
options

Options

Name Type Description
className string

Class name for CSS styling. Default empty.

color string

Label color. Default value '#000000'

background string

Label backgroud. The string format is the same than css tag. Default value 'none repeat scroll 0% 0% #ffffff'

fontWeight boolean

Bold text. Default: false

offset Array.<number>

Label offset, in pixels, from the bottom position of icon. Default value for default label is [-3, -18].

show boolean

Show text. Default value 1.

text string

Simple Label text (with no background).

Methods

getElement(){Element}

Return DOM Element.

Obtain marker.

Returns:
Marker.

getText(){string}

Obtain text

Returns:
Label text

hide()

Hide element on map

isVisible(){boolean}

Returns:
if popup is opened or not. Values: true or false.

setPosition(position)

Change label position.

Name Type Description
position module:cercaliagl/LonLat~LonLat

Position

setText(text)

Change label text content. It can be HTML string. For example <b>Bold</b> text label

Name Type Description
text string

Text to display on label.

show()

Show element on map