MMapGeolocationControl

The MMapGeolocationControl class determines a user's location by calling the browser's standard geolocation function and/or identifying their IP address.

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

Add the location button:

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

const controls = new MMapControls();
controls.addChild(new MMapGeolocationControl());

map.addChild(controls);

Detailed example.

Constructor

new MMapGeolocationControl(props)

Constructor parameters

Parameter

Type

props

MMapGeolocationControlProps

Redefines

MMapGroupEntity.constructor

Props

MMapGeolocationControlProps: Object

Parameters

Parameter

Type

Description

duration?

number

Duration of location animation on the map.

easing?

EasingFunctionDescription

Easing function for animating the location on the map.

onGeolocatePosition?

(position: LngLat) => void

Callback of a geolocation request.

source?

string

ID of the data source for a geolocation tag.

zoom?

number

Map scale after the location is determined.

Methods

addChild

addChild(child, index?): MMapGeolocationControl

Parameters

Parameter

Type

child

MMapEntity<unknown, {}>

index?

number

Returns

MMapGeolocationControl

Inherited from

MMapGroupEntity.addChild

removeChild

removeChild(child): MMapGeolocationControl

Parameters

Parameter

Type

child

MMapEntity<unknown, {}>

Returns

MMapGeolocationControl

Inherited from

MMapGroupEntity.removeChild

update

update(changedProps): void

Parameters

Parameter

Type

Description

changedProps

Partial<MMapGeolocationControlProps>

New props values.

Returns

void

Inherited from

MMapGroupEntity.update