MapContext.getCenterLocation

Get the center location of the current map.

Parameters

PropertyType

Required

Description
successFunctionNoThe callback method that indicates a successful call.
failFunctionNo The callback method that indicates a failed call.
completeFunctionNoThe callback method that indicates the call is completed (this will be executed regardless of whether the call succeeds or fails).

Success callback function

The parameters are in object type and have the following properties:

PropertyTypeDescription
longitudeNumberLongitude.
latitudeNumberLatitude.

Sample code

copy
// .js
this.mapCtx = my.createMapContext('map');
this.mapCtx.getCenterLocation({
success: res => {
my.alert({
    content: 'longitude:' + res.longitude + '\nlatitude:' + res.latitude,
});
console.log(res.longitude);
console.log(res.latitude);
}
});