YMapControlButton

The YMapControlButton class is a component for creating a button control element.

Usage example

Adding a button that moves the map center to Moscow:

const map = new YMap(element, {
  location: {center: [37.588144, 55.733842], zoom: 14}
});

const controls = new YMapControls({position: 'top left'});
const button = new YMapControlButton({
  text: 'Moscow',
  onClick: () => {
    map.setLocation({
      center: [37.588144, 55.733842],
      zoom: 5
    });
  }
});

controls.addChild(button);
map.addChild(controls);

The YMapControlButton class is used to add a standard button and set up custom behavior for it.

Example

const button = new YMapControlButton({
  text: 'Hello',
  onClick: () => alert('Hello world!')
});

Detailed example.

Constructor

new YMapControlButton(props, options?)

Constructor parameters

Parameter

Type

props

YMapControlCommonButtonProps

children?

GenericEntity<unknown, {}, YMap>[]

options?

Omitref<ComplexOptions<YMap>, "children">

Inherited from

YMapComplexEntity.constructor

new YMapControlButton(props, children?, options?)

Parameters

Parameter

Type

props

YMapControlCommonButtonProps

children?

GenericEntity<unknown, {}, YMap>[]

options?

Omit<ComplexOptions<YMap>, "children">

Inherited from

YMapComplexEntity.constructor

Props

YMapControlButtonProps: <a href="#YMapControlCommonButtonProps">YMapControlCommonButtonProps

Parameters

Parameter

Type

Description

background?

string

Background color.

color?

string

Text color.

disabled?

boolean

Must be disabled.

element?

HTMLElement

HTML element.

onClick?

() => void

Onclick handler.

text?

string

Content text.

Methods

update

update(changedProps): void

Parameters

Parameter

Type

Description

changedProps

Partial<YMapControlCommonButtonProps>

New props values.

Returns

void

Inherited from

YMapComplexEntity.update