MMapControlButton

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

Usage example

Adding a button that moves the map center to Dubai:

const map = new MMap(element, {
  location: {center: [25.229762, 55.289311], zoom: 14}
});

const controls = new MMapControls({position: 'top left'});
const button = new MMapControlButton({
  text: 'Dubai',
  onClick: () => {
    map.setLocation({
      center: [25.229762, 55.289311],
      zoom: 5
    });
  }
});

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

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

Example

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

Detailed example.

Constructor

new MMapControlButton(props, options?)

Constructor parameters

Parameter

Type

props

MMapControlCommonButtonProps

children?

GenericEntity<unknown, {}, MMap>[]

options?

Omitref<ComplexOptions<MMap>, "children">

Inherited from

MMapComplexEntity.constructor

new MMapControlButton(props, children?, options?)

Parameters

Parameter

Type

props

MMapControlCommonButtonProps

children?

GenericEntity<unknown, {}, MMap>[]

options?

Omit<ComplexOptions<MMap>, "children">

Inherited from

MMapComplexEntity.constructor

Props

MMapControlButtonProps: <a href="#MMapControlCommonButtonProps">MMapControlCommonButtonProps

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<MMapControlCommonButtonProps>

New props values.

Returns

void

Inherited from

MMapComplexEntity.update