This method is used via wx.getLocation(Object object).
Attribute | Type | Default value | Required | Description |
type | string | wgs84 | No | WGS84 returns GPS coordinates, while GCJ02 provides coordinates that can be used with wx.openLocation. |
altitude | string | false | No | Passing in "true" will return altitude information. As acquiring altitude requires high precision, it will slow down the response of the interface. |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
latitude | number | Latitude, ranging from -90 to 90, with negative values indicating southern latitude. |
longitude | number | Longitude, ranging from -180 to 180, with negative values indicating western longitude. |
speed | number | Velocity, measured in meters per second (m/s) |
accuracy | number | Precision of the location |
altitude | number | Height, measured in (m) |
verticalAccuracy | number | Vertical accuracy, measured in meters (m). (Cannot be obtained on Android, returning 0) |
horizontalAccuracy | number | Horizontal accuracy, measured in meters (m) |
wx.getLocation({type: 'gcj02',success (res) {const latitude = res.latitudeconst longitude = res.longitudeconst speed = res.speedconst accuracy = res.accuracy}})
This API is used via wx.choosePoi(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
type | number | When selecting a city, the value is 1; when selecting an exact location, the value is 2. |
city | number | City Name |
name | string | Location Name |
address | string | Exact Address |
latitude | number | Latitude, a floating-point number, ranging from -90 to 90, where a negative number indicates southern latitude, using the gcj02 National Administration of Surveying, Mapping and Geoinformation coordinate system (to be deprecated). |
longitude | number | Longitude, a floating-point number, ranging from -180 to 180, where a negative number indicates western longitude, using the gcj02 National Administration of Surveying, Mapping and Geoinformation coordinate system (to be deprecated). |
This API is used via wx.chooseLocation(Object object).
Attribute | Type | Default value | Required | Description |
type | string | tencent | No | Tencent Maps (tencent), Google Maps (google), supported by IDE only. |
latitude | number | - | No | Target location's latitude. |
longitude | number | - | No | Target location's longitude. |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
name | string | Location Name |
address | string | Exact Address |
latitude | number | Latitude, a floating-point number, ranging from -90 to 90, where a negative number indicates southern latitude, using the gcj02 National Administration of Surveying, Mapping and Geoinformation coordinate system. |
longitude | number | Longitude, a floating-point number, ranging from -180 to 180, where a negative number indicates western longitude, using the gcj02 National Administration of Surveying, Mapping and Geoinformation coordinate system. |
This API is used via wx.stopLocationUpdate(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
This API is used via wx.startLocationUpdateBackground(Object object).
Attribute | Type | Default value | Required | Description |
type | string | gcj02 | No | WGS84 returns GPS coordinates, while GCJ02 provides coordinates that can be used with wx.openLocation. |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
This API is used via wx.startLocationUpdate(Object object).
Attribute | Type | Default value | Required | Description |
type | string | Coordinates, gcj02 | No | WGS84 returns GPS coordinates, while GCJ02 provides coordinates that can be used with wx.openLocation. |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
This API is used via wx.openLocation(Object object).
Attribute | Type | Default value | Required | Description |
type | string | tencent | No | Tencent Maps (tencent), Google Maps (google), supported by IDE only. |
latitude | number | - | Yes | Latitude, ranging from -90 to 90, where a negative number indicates southern latitude, using the gcj02 National Administration of Surveying, Mapping and Geoinformation coordinate system. |
longitude | number | - | Yes | Longitude, ranging from -180 to 180, where a negative number indicates western longitude, using the gcj02 National Administration of Surveying, Mapping and Geoinformation coordinate system. |
scale | number | 18 | No | Zoom scale, ranging from 5 to 18. |
name | string | - | No | Location Name |
address | string | - | No | Detailed description of the address. |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
wx.getLocation({type: 'gcj02', // Returns longitude and latitude that can be used for wx.openLocation.success (res) {const latitude = res.latitudeconst longitude = res.longitudewx.openLocation({latitude,longitude,scale: 18})}})
This API is used via wx.onLocationChangeError(function listener).
Attribute | Type | Description |
errCode | number | errCode |
This API is used via wx.onLocationChange(function listener).
Attribute | Type | Description |
latitude | number | Latitude, ranging from -90 to 90, where a negative number indicates southern latitude, using the gcj02 National Administration of Surveying, Mapping and Geoinformation coordinate system. |
longitude | number | Longitude, ranging from -180 to 180, where a negative number indicates western longitude, using the gcj02 National Administration of Surveying, Mapping and Geoinformation coordinate system. |
speed | number | Velocity, measured in meters per second (m/s) |
accuracy | number | Precision of the location |
altitude | number | Height, measured in (m) |
verticalAccuracy | number | Vertical accuracy, measured in meters (m). (Cannot be obtained on Android, returning 0) |
horizontalAccuracy | number | Horizontal accuracy, measured in meters (m) |
const _locationChangeFn = function(res) {console.log('location change', res)}wx.onLocationChange(_locationChangeFn)wx.offLocationChange(_locationChangeFn)
This API is used via wx.offLocationChangeError(function listener).
const listener = function (res) { console.log(res) }wx.onLocationChangeError(listener)wx.offLocationChangeError(listener) // You need to pass the same function object as when you were listening.
This API is used via wx.offLocationChange(function listener).
const listener = function (res) { console.log(res) }wx.onLocationChangeError(listener)wx.offLocationChangeError(listener) // You need to pass the same function object as when you were listening.
This API is used via wx.getFuzzyLocation(Object object).
Attribute | Type | Default value | Required | Description |
type | string | wgs84 | No | WGS84 returns GPS coordinates, while GCJ02 provides coordinates that can be used with wx.openLocation. |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
latitude | number | Latitude, ranging from -90 to 90, with negative values indicating southern latitude. |
longitude | number | Longitude, ranging from -180 to 180, with negative values indicating western longitude. |
wx.getFuzzyLocation({type: 'wgs84',success (res) {const latitude = res.latitudeconst longitude = res.longitude}})
Was this page helpful?