MMapHint

A hint is a popup text that can display any HTML content.
The MMapHint class displays hints on map elements.

Note

This class is a JS API package component and provides additional features not included in the core API.

To integrate the package, follow the instructions.

Usage example

const {MMapHint, MMapHintContext} = await mappable.import('@mappable-world/mappable-hint@0.0.1');
map.addChild(defaultFeatures = new MMapDefaultFeaturesLayer());
map.addChild(hint = MMapHint({
   layers: [defaultFeatures.layer],
   hint: object => object?.properties?.hint
}));

const {MMapDefaultMarker} = await mappable.import('@mappable-world/mappable-markers@0.0.1');
map.addChild(new MMapDefaultMarker({coordinates: [37, 55], properties: {hint: 'Hello world!'}}));

hint.addChild(new class MyHint extends mappable.MMapEntity {
   _onAttach() {
        this._element = document.createElement('div');
        this._element.className = 'my-hint';

        this._detachDom = mappable.useDomContext(this, this._element);
        this._watchContext(MMapHintContext, () => {
             this._element.textContent = this._consumeContext(MMapHintContext)?.hint;
        }, {immediate: true});
   }

   _onDetach() {
       this._detachDom();
       this._detachDom = undefined;
   }
});

Detailed example.

Constructor

new MMapHint(props)

Constructor parameters

Parameter

Type

props

MMapHintProps

Redefines

MMapGroupEntity.constructor

Props

MMapHintProps: Object

Parameters

Parameter

Type

hint

(object: MMapFeature | MMapMarker | MMapHotspot | undefined) => unknown

Methods

addChild

addChild(child, index?): MMapHint

Parameters

Parameter

Type

child

MMapEntity<unknown, {}>

index?

number

Returns

MMapHint

Inherited from

MMapGroupEntity.addChild

removeChild

removeChild(child): MMapHint

Parameters

Parameter

Type

child

MMapEntity<unknown, {}>

Returns

MMapHint

Inherited from

MMapGroupEntity.removeChild

update

update(changedProps): void

Parameters

Parameter

Type

Description

changedProps

Partial<MMapHintProps>

New props values.

Returns

void

Inherited from

MMapGroupEntity.update

Previous