YMapGeolocationControl

The YMapGeolocationControl 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 YMap(element, {
  location: {center: [37.588144, 55.733842], zoom: 14}
});

const controls = new YMapControls();
controls.addChild(new YMapGeolocationControl());

map.addChild(controls);

Detailed example.

Constructor

new YMapGeolocationControl(props)

Constructor parameters

Parameter

Type

props

YMapGeolocationControlProps

Redefines

YMapGroupEntity.constructor

Props

YMapGeolocationControlProps: 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?): YMapGeolocationControl

Parameters

Parameter

Type

child

YMapEntity<unknown, {}>

index?

number

Returns

YMapGeolocationControl

Inherited from

YMapGroupEntity.addChild

removeChild

removeChild(child): YMapGeolocationControl

Parameters

Parameter

Type

child

YMapEntity<unknown, {}>

Returns

YMapGeolocationControl

Inherited from

YMapGroupEntity.removeChild

update

update(changedProps): void

Parameters

Parameter

Type

Description

changedProps

Partial<YMapGeolocationControlProps>

New props values.

Returns

void

Inherited from

YMapGroupEntity.update