Appearance
Location
openLocation
iOS needs to rely on either the Extension SDK or MapSDK, and if it relies on both the Extension SDK and MapSDK, the openLocation provided by MapSDK is preferred.
Android needs to rely on MapSDK (Google solution is not supported at the moment)
openLocation(Object object)
Check your location using WeChat's built-in map
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
latitude | number | yes | Latitude, range -9090. The negative number indicates latitude south. use gcj02 NBS coordinate system | |
longitude | number | yes | Longitude, range -180Negative numbers denote west longitude. use gcj02 NBS coordinate system | |
scale | number | 16 | no | Scale, Range 518 |
name | string | no | Location name | |
address | string | no | A detailed explaination of the address | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.getLocation({
type: 'gcj02', //Returns the latitude and longitude that can be used for wx.openLocation
success (res) {
const latitude = res.latitude
const longitude = res.longitude
ft.openLocation({
latitude,
longitude,
scale: 18
})
}
})
Note
- Interface authorization failure (iOS). 1:
- the user refuses to authorise, an error message is returned: unauthorized, the user has not granted location permissions
- The host app disables the mini program from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting location permissions.
- Interface authorization failure (Android).
- the user refuses to authorize, then the MapView locates to the default location, and the location can be subsequently searched and selected manually
getLocation
Base library support from 1.3.9, iOS version 2.1.23
iOS depends on extension SDK
Android depends on either the Extension SDK or the MapSDK, if both the Extension SDK and the MapSDK are relied on, the getLocation provided by the MapSDK is used in preference.
Android using the Extension SDK can integrate MapSDK if it encounters slow location and the success rate of location does not meet the demand, and use the location capability provided by the third-party location SDK (Gaode, Baidu, Google), no it is recommended to use getLocation provided by the Extension SDK.
getLocation(Object object)
Gets the current location and speed. This interface cannot be invoked when the user leaves the Mini Program. Enable high-precision positioning, interface time will increase, can be specified highAccuracyExpireTime As a timeout. The format of coordinates used in relation to the map should read gcj02。 High frequency calls cause power consumption, use persistent location interface if required ft.onLocationChangeBase
library. 2.17.0
Version from wx.getLocation Increasing the call frequency limit,Related announcements
。
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
type | string | wgs84 | no | wgs84 return gps Coordinates, gcj02 Return can be used for wx.openLocation Coordinates |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) | |
object.success callback |
Note
- Interface authorization failure (iOS). 1:
- the user refuses to authorise, an error message is returned: unauthorized, the user has not granted location permissions
- The host app disables the mini program from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting location permissions.
- Interface authorization failure (Android).
- the user refuses to authorise, an error message will be returned: unauthorized the user has not granted permission to obtain location information
- the host app prohibits the mini program from actively requesting permissions, the error message is returned: unauthorized disableauthorized SDK is prohibited from initiating permission requests
choosePoi
iOS depends on extension SDK
Android requires MapSDK dependency (Google solution not supported at this time)
choosePoi(Object object)
Open the map to select the location, support fuzzy positioning (accurate to the city) and precise positioning mixed election
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
type | number | When selecting a city, the value is When selecting the exact position, the value is 2 |
city | string | City name |
name | string | Location name |
address | string | Detailed address |
latitude | string | Latitude, floating point, range -9090. The negative number indicates latitude south. use gcj02 NBS coordinate system |
longitude | string | Longitude, float, range -180Negative numbers denote west longitude. use gcj02 NBS coordinate system |
Note
- Interface authorization failure (iOS). 1:
- the user refuses to authorise, an error message is returned: unauthorized, the user has not granted location permissions
- The host app disables the mini program from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting location permissions.
- Interface authorization failure (Android).
- the user refuses to authorize, then the MapView locates to the default location, and the location can be subsequently searched and selected manually
chooseLocation
Base library 1.3.9 supported since, iOS version 2.1.23
iOS needs to rely on either the Extension SDK or MapSDK, if both the Extension SDK and MapSDK are relied on, the openLocation provided by MapSDK is preferred.
Android needs to rely on MapSDK (Google solutions are not supported at the moment)
chooseLocation(Object object)
Open the map and select the location
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
latitude | number | no | Target latitude | |
longitude | number | no | Target longitude | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
name | string | Location name |
address | string | Detailed address |
latitude | string | Latitude, floating point, range -9090. The negative number indicates latitude south. use gcj02 NBS coordinate system |
longitude | string | Longitude, float, range -180Negative numbers denote west longitude. use gcj02 NBS coordinate system |
Note
- Interface authorization failure (iOS). 1:
- the user refuses to authorise, an error message is returned: unauthorized, the user has not granted location permissions
- The host app disables the mini program from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting location permissions.
- Interface authorization failure (Android).
- the user refuses to authorize, then the MapView locates to the default location, and the location can be subsequently searched and selected manually