Skip to content

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

attributetypeDefault valuesRequiredIntroductions
latitudenumberyesLatitude, range -9090. The negative number indicates latitude south. use gcj02 NBS coordinate system
longitudenumberyesLongitude, range -180Negative numbers denote west longitude. use gcj02 NBS coordinate system
scalenumber16noScale, Range 518
namestringnoLocation name
addressstringnoA detailed explaination of the address
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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:
  1. the user refuses to authorise, an error message is returned: unauthorized, the user has not granted location permissions
  2. 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).
  1. 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

attributetypeDefault valuesRequiredIntroductions
typestringwgs84nowgs84 return gps Coordinates, gcj02 Return can be used for wx.openLocation Coordinates
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)
object.success callback

Note

  • Interface authorization failure (iOS). 1:
  1. the user refuses to authorise, an error message is returned: unauthorized, the user has not granted location permissions
  2. 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).
  1. the user refuses to authorise, an error message will be returned: unauthorized the user has not granted permission to obtain location information
  2. 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
typenumberWhen selecting a city, the value is When selecting the exact position, the value is 2
citystringCity name
namestringLocation name
addressstringDetailed address
latitudestringLatitude, floating point, range -9090. The negative number indicates latitude south. use gcj02 NBS coordinate system
longitudestringLongitude, float, range -180Negative numbers denote west longitude. use gcj02 NBS coordinate system

Note

  • Interface authorization failure (iOS). 1:
  1. the user refuses to authorise, an error message is returned: unauthorized, the user has not granted location permissions
  2. 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).
  1. 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

attributetypeDefault valuesRequiredIntroductions
latitudenumbernoTarget latitude
longitudenumbernoTarget longitude
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
namestringLocation name
addressstringDetailed address
latitudestringLatitude, floating point, range -9090. The negative number indicates latitude south. use gcj02 NBS coordinate system
longitudestringLongitude, float, range -180Negative numbers denote west longitude. use gcj02 NBS coordinate system

Note

  • Interface authorization failure (iOS). 1:
  1. the user refuses to authorise, an error message is returned: unauthorized, the user has not granted location permissions
  2. 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).
  1. the user refuses to authorize, then the MapView locates to the default location, and the location can be subsequently searched and selected manually