MapContext.getCenterLocation
Get the center location of the current map.
Parameters
Property | Type | Required | Description |
success | Function | No | The callback method that indicates a successful call. |
fail | Function | No | The callback method that indicates a failed call. |
complete | Function | No | The 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:
Property | Type | Description |
longitude | Number | Longitude. |
latitude | Number | Latitude. |
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);
}
});