Location
# openLocation
iOS depends on the extension SDK or MapSDK, and if you rely on both the extension SDK and the MapSDK, the openLocation provided by the MapSDK is preferred.
Android depends on MapSDK (Google solutions are not supported yet)
openLocation(Object object)
Use the built-in map to view locations
Parameters
Object object
| Properties | Type | The default value is | Required | Description |
|---|---|---|---|---|
| latitude | number | Yes | Latitude, ranging from -90 to 90, negative numbers indicate southern latitude. Use the GCJ02 INA coordinate system | |
| longitude | number | Yes | Longitude, ranging from -180 to 180, negative numbers indicate west longitude. Use the GCJ02 INA coordinate system | |
| scale | number | 16 | No | Scale, ranging from 5 to 18 |
| name | string | No | Location name | |
| address | string | No | A detailed description of the address | |
| success | function | No | The interface calls the callback function successfully | |
| fail | function | No | The callback function that failed the interface callback function | |
| complete | function | No | The callback function at the end of the interface call (the call succeeds or fails) |
Sample Code
note
- Interface Authorization Failed (iOS):
- The user refuses authorization and returns an error message: unauthorized, the user did not grant location permissions
- The host App prohibits the Mini App from actively applying for permissions, and will return an error message: unauthorized disableauthorized, sdk is forbidden to apply for location permissions
- Interface authorization failed (Android):
- If the user refuses authorization, the map view is located to the default location, and then the location can be manually searched and selected
# getLocation
Base Library 1.3.9 is supported, iOS version 2.1.23
iOS relies on the extension SDK
Android depends on the extension SDK or MapSDK, and if you rely on both the extension SDK and the MapSDK, the getLocation provided by the MapSDK is preferred.
Android uses the extension SDK If you encounter a situation where the positioning is slow and the positioning success rate does not meet the needs, you can integrate the MapSDK and use the positioning capabilities provided by the third-party positioning SDK (AutoNavi, Baidu, Google), otherwise it is recommended to use the getLocation provided by the extension SDK.
getLocation(Object object)
Get information such as the current geographic location. When the user leaves the MiniApp, this interface cannot be called.
Parameters
Object object
| Properties | Type | The default value is | Required | Description |
|---|---|---|---|---|
| type | string | gcj02 | No | Currently, the gcj02 coordinate is returned regardless of the parameter. |
Note: Android does not support this property.
Android returns gcj02 if it is using getLocation provided by the extension SDK.
If you are using getLocation provided by MapSDK, AutoNavi and Baidu return gcj02 in domestic regions, wgs84 in foreign regions, and wgs84 in Google and abroad.
The actual return value is based on the value of the type property of the success callback function. And do a good job of coordinate conversion processing.
| | success | function | | No | The interface calls the callback function successfully | | fail | function | | No | The callback function that failed the interface callback function | | complete | function | | No | The callback function at the end of the interface call (the call succeeds or fails) |
note
- Interface Authorization Failed (iOS):
- The user refuses authorization and returns an error message: unauthorized, the user did not grant location permissions
- The host App prohibits the Mini App from actively applying for permissions, and will return an error message: unauthorized disableauthorized, sdk is forbidden to apply for location permissions
- Interface authorization failed (Android):
- The user denies authorization and returns an error message: Unauthorized The user has not been granted permission to obtain location information
- The host App prohibits the Mini App from actively applying for permissions, and will return an error message: Unauthorized disableauthorized SDK is prohibited from initiating permission applications
# choosePoi
iOS relies on the extension SDK
Android depends on MapSDK (Google solutions are not supported yet)
choosePoi(Object object)
Open the POI list to select a location, support fuzzy positioning (accurate to the city) and accurate positioning mixing.
Parameters
Object object
| Properties | Type | The default value is | Required | Description |
|---|---|---|---|---|
| success | function | No | The interface calls the callback function successfully | |
| fail | function | No | The callback function that failed the interface callback function | |
| complete | function | No | The callback function at the end of the interface call (the call succeeds or fails) |
object.success callback function
Parameters
Object res
| Properties | Type | Description |
|---|---|---|
| type | number | The value is 0 when you choose not to show locations, 1 when you select a city, and 2 |
| city | string | City name |
| name | string | Location Name |
| address | string | Full address |
| latitude | string | Latitude, floating-point number, range -90 to 90, negative numbers represent southern latitude. Use the GCJ02 INA coordinate system |
| longitude | string | Longitude, floating-point number, in the range -180 to 180, negative numbers represent west longitude. Use the GCJ02 INA coordinate system |
note
- Interface Authorization Failed (iOS):
- The user refuses authorization and returns an error message: unauthorized, the user did not grant location permissions
- The host App prohibits the Mini App from actively applying for permissions, and will return an error message: unauthorized disableauthorized, sdk is forbidden to apply for location permissions
- Interface authorization failed (Android):
- If the user refuses authorization, the map view is located to the default location, and then the location can be manually searched and selected
# chooseLocation
Base Library 1.3.9 is supported, iOS version 2.1.23
iOS depends on the extension SDK or MapSDK, and if you rely on both the extension SDK and the MapSDK, the openLocation provided by the MapSDK is preferred.
Android depends on MapSDK (Google solutions are not supported yet)
chooseLocation(Object object)
Open the map to select a location.
Parameters
Object object
| Properties | Type | The default value is | Required | Description |
|---|---|---|---|---|
| latitude | number | No | The target latitude is | |
| longitude | number | No | Target longitude | |
| success | function | No | The interface calls the callback function successfully | |
| fail | function | No | The callback function that failed the interface callback function | |
| complete | function | No | The callback function at the end of the interface call (the call succeeds or fails) |
object.success callback function
Parameters
Object res
| Properties | Type | Description |
|---|---|---|
| name | string | Location Name |
| address | string | Full address |
| latitude | string | Latitude, floating-point number, range -90 to 90, negative numbers represent southern latitude. Use the GCJ02 INA coordinate system |
| longitude | string | Longitude, floating-point number, in the range -180 to 180, negative numbers represent west longitude. Use the GCJ02 INA coordinate system |
note
- Interface Authorization Failed (iOS):
- The user refuses authorization and returns an error message: unauthorized, the user did not grant location permissions
- The host App prohibits the Mini App from actively applying for permissions, and will return an error message: unauthorized disableauthorized, sdk is forbidden to apply for location permissions
- Interface authorization failed (Android):
- If the user refuses authorization, the map view is located to the default location, and then the location can be manually searched and selected