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!')
});
Constructor
new YMapControlButton(props, options?)
Constructor parameters
|
Parameter |
Type |
|
|
|
|
|
|
|
|
|
Inherited from
new YMapControlButton(props, children?, options?)
Parameters
|
Parameter |
Type |
|
|
|
|
|
|
|
|
|
Inherited from
Props
YMapControlButtonProps: <a href="#YMapControlCommonButtonProps">YMapControlCommonButtonProps
Parameters
|
Parameter |
Type |
Description |
|
|
|
Background color. |
|
|
|
Text color. |
|
|
|
Must be disabled. |
|
|
HTML element. |
|
|
|
() => |
Onclick handler. |
|
|
|
Content text. |
Methods
update
update(changedProps): void
Parameters
|
Parameter |
Type |
Description |
|
|
New props values. |
Returns
void