All Products
Search
Document Center

SuperApp:Geographic location

Last Updated:Jun 02, 2026

WVLocation provides JavaScript APIs for geographic location in WindVane HTML5 apps and miniapps. Use WVLocation.getLocation to retrieve the device's current position and WVLocation.searchLocation to resolve an address to coordinates.

WVLocation.getLocation

Retrieves the device's current geographic location.

Note

iOS requires the following configuration before calling this API:

  • iOS 8–10: add NSLocationWhenInUseUsageDescription and NSLocationAlwaysUsageDescription to Info.plist to trigger the location permission prompt.

  • iOS 11 and later: add NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription to Info.plist.

  • All iOS versions: register EMASUserInfoService before calling this API.

Input parameters

Parameter

Type

Required

Description

enableHighAccuracy

string

No

Specifies whether to request a high-accuracy location. Valid values: true, false. Default: false.

address

boolean

No

Specifies whether to include a reverse-geocoded address (such as city and province) in the response. Setting this to false reduces response time. Valid values: true, false. Default: false.

Success response

The callback receives an object with the following fields.

coords — coordinates object (object)

Field

Type

Description

longitude

string

Longitude of the location.

latitude

string

Latitude of the location.

accuracy

string

Accuracy radius, in meters.

address — address object (object, returned only when address: true)

Field

Type

Description

city

string

City name.

province

string

Province name.

area

string

District name.

road

string

Road name.

addressLine

string

Full formatted address.

cityCode

string

City code. Available only on Taobao Android apps. Non-Taobao Android apps and Google-based responses do not include this field.

Important

Location accuracy and the underlying location provider affect the address fields returned. Some fields may be missing or inaccurate. Add error handling for incomplete or unexpected address data in your HTML5 apps or miniapps.

Example

var params = {
        // Whether to request a high-accuracy location.
        enableHighAccuracy: true,
        // Whether to include the reverse-geocoded address.
        address: true
};
window.WindVane.call('WVLocation', 'getLocation', params, function(e) {
        alert('success:' + JSON.stringify(e));
}, function(e) {
        alert('failure:' + JSON.stringify(e));
});

Example success response:

{
  "coords": {
    "longitude": "120.126293",
    "latitude": "30.274653",
    "accuracy": "200"
  },
  "address": {
    "city": "Hangzhou",
    "province": "Zhejiang",
    "area": "Xihu District",
    "road": "Xueyuan Road",
    "addressLine": "No.77 Xueyuan Road, Xihu District, Hangzhou",
    "cityCode": "0571"
  }
}

WVLocation.searchLocation

Note

This API is available only in WindVane iOS.

Resolves an address string to geographic coordinates (latitude and longitude).

Input parameters

Parameter

Type

Required

Description

addrs

string

Yes

The address to resolve.

Success response

The callback receives an object with the following fields.

Field

Type

Description

longitude

string

Longitude of the resolved address.

latitude

string

Latitude of the resolved address.

Example

var params = {
        // The address to resolve.
        addrs: ' No.960 xxxx West Road'};
window.WindVane.call('WVLocation', 'searchLocation', params, function(e) {
        alert('success:' + JSON.stringify(e));
}, function(e) {
        alert('failure:' + JSON.stringify(e));
});