layout.templateBased.Base

Extends ILayout.

Basic layout class based on templates. This class is used by the layout factory as a base for creating user layouts.

See templateLayoutFactory

Constructor | Fields | Events | Methods

Constructor

layout.templateBased.Base(data)

Parameters:

Parameter

Default value

Description

data*

Type: Object

Set of different types of data that are used for building a layout.

* Mandatory parameter/option.

Fields

Name

Type

Description

events

IEventManager

Event manager.

Inherited from IDomEventEmitter.

Events

Name

Description

click

Single left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

contextmenu

Calls the element's context menu. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

dblclick

Double left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

emptinesschange

Change to the empty layout indicator. Instance of the Event class.

Inherited from ILayout.

mousedown

Pressing the mouse button over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mouseenter

Pointing the cursor at the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mouseleave

Moving the cursor off of the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mousemove

Moving the cursor over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mouseup

Letting go of the mouse button over an object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

multitouchend

End of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface.

Inherited from IDomEventEmitter.

multitouchmove

Repeating event during multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields:

  • clientX - X coordinate of the touch relative to the viewable area of the browser.
  • clientY - Y coordinate of the touch relative to the viewable area of the browser.
  • pageX - X coordinate of the touch relative to the beginning of the document.
  • pageY - Y coordinate of the touch relative to the beginning of the document.

Inherited from IDomEventEmitter.

multitouchstart

Start of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields:

  • clientX - X coordinate of the touch relative to the viewable area of the browser.
  • clientY - Y coordinate of the touch relative to the viewable area of the browser.
  • pageX - X coordinate of the touch relative to the beginning of the document.
  • pageY - Y coordinate of the touch relative to the beginning of the document.

Inherited from IDomEventEmitter.

parentelementchange

Change to the parent element. Instance of the Event class.

Inherited from ILayout.

shapechange

Change to the shape of the area spanning the layout. Instance of the Event class.

Inherited from ILayout.

wheel

Mouse wheel scrolling. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

Methods

Name

Returns

Description

build()

Builds a layout instance based on the template and adds it to the parent HTML element.

clear()

Removes layout content from DOM.

destroy()

Destructor. Called when activity with the layout is finished.

Inherited from ILayout.

getData()

Object

Returns layout data object.

Inherited from ILayout.

getParentElement()

HTMLElement

Returns parent HTML element.

Inherited from ILayout.

getShape()

IShape|null

Returns a shape that defines the area spanning the layout, or null if it is not possible to plot this shape. By default, it tries to construct a shape via the "shape" option - this.getData().options.get('shape'). In the option, it can be set as an instance of a class implementing the IShape interface, or as a JSON description of the shape's pixel geometry. Coordinates of the shape's geometry should be calculated from the anchor point of the parent layout element.

isEmpty()

Boolean

Returns true if the layout is empty, i.e. it does not have any content. This indicator is used for hiding empty objects such as hints, balloons, and others.

Inherited from ILayout.

onSublayoutSizeChange(sublayoutInfo, nodeSizeByContent)

Automatically called when resizing a nested layout, added with the observeSize option. Used to override specific classes of layouts to respond to the resizing of the content.

rebuild()

Re-sets the layout.

setData(data)

Sets layout data.

Inherited from ILayout.

setParentElement(parent)

Adds the layout to the DOM tree.

Inherited from ILayout.

Methods details

build

{} build()

Builds a layout instance based on the template and adds it to the parent HTML element.

clear

{} clear()

Removes layout content from DOM.

getShape

{IShape|null} getShape()

Returns a shape that defines the area spanning the layout, or null if it is not possible to plot this shape. By default, it tries to construct a shape via the "shape" option - this.getData().options.get('shape'). In the option, it can be set as an instance of a class implementing the IShape interface, or as a JSON description of the shape's pixel geometry. Coordinates of the shape's geometry should be calculated from the anchor point of the parent layout element.

Example:

// Creating a placemark and setting a circular interactive area for it.
var MyLayoutClass = ymaps.templateLayoutFactory.createClass('<div class="imageIcon">{{name}}</div>');
var myPlacemark = new ymaps.Placemark([22, 34], {name: 'Cafe Mayak'}, {
    iconLayout: MyLayoutClass,
    iconShape: {type: 'Circle', coordinates: [0, 0], radius: 20}
});

onSublayoutSizeChange

{} onSublayoutSizeChange(sublayoutInfo, nodeSizeByContent)

Automatically called when resizing a nested layout, added with the observeSize option. Used to override specific classes of layouts to respond to the resizing of the content.

Parameters:

Parameter

Default value

Description

sublayoutInfo*

Type: Object

Information about the nested layout.

nodeSizeByContent*

Type: Object

The new size of the element considering the size of its content. Available fields: width, height, scrollX, scrollY.

* Mandatory parameter/option.

rebuild

{} rebuild()

Re-sets the layout.