title: Taro.chooseLocation(option)

sidebar_label: chooseLocation

Opens the map to select a location.

Reference

Type

  1. (option: Option) => Promise<SuccessCallbackResult>

Parameters

Option

Property Type Required Description
latitude number No Latitude.
longitude number No Longitude.
complete (res: any) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
fail (res: any) => void No The callback function for a failed API call
success (res: Result) => void No The callback function for a successful API call

SuccessCallbackResult

Property Type Description
address string Detailed address
latitude string Latitude. The value ranges from -90 to +90, and the negative number means south latitude. The GCJ-02 coordinate system of the State Bureau of Surveying and Mapping is used.
longitude string Longitude. The value ranges from -180 to +180, and the negative number means west longitude. The GCJ-02 coordinate system of the State Bureau of Surveying and Mapping is used.
name string Location name
errMsg string Call result

Sample Code

  1. // config/index.js
  2. // Once you have obtained the api key, you will need to fill it into the project's constant configuration `defineConstants.LOCATION_APIKEY`:
  3. const config = {
  4. defineConstants: {
  5. LOCATION_APIKEY: JSON.stringify('XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX')
  6. },
  7. // ...
  8. }

API Support

API WeChat Mini-Program H5 React Native
Taro.chooseLocation ✔️ ✔️