Location Kit allows your system to identify the location of a mobile device with its coordinates, and uses location technologies such as Global Navigation Satellite System (GNSS) and network positioning (for example, base station positioning or WLAN/Bluetooth positioning) to provide diverse location-based services.
In addition to providing basic services, Location Kit also provides functionalities and APIs, such as geofencing, geocoding, reverse geocoding, and country code.
A coordinate describes a location on the earth using the longitude and latitude in reference to World Geodetic System–1984 Coordinate System (WGS-84).
GNSS positioning locates a mobile device by using the location algorithm offered by the device chip to compute the location information provided by the Global Navigation Satellite System, for example, GPS, GLONASS, BeiDou, and Galileo. Whichever positioning system will be used during the location process depends on the hardware capability of the device.
Base station positioning estimates the current location of a mobile device based on the location of the resident base station in reference to the neighboring base stations. This technology provides only a lower accuracy and requires access to the cellular network.
WLAN or Bluetooth positioning estimates the current location of a mobile device based on the locations of WLANs and Bluetooth devices that can be discovered by the device. The location accuracy of this technology depends on the distribution of fixed WLAN access points (APs) and Bluetooth devices around the device. A higher density of WLAN APs and Bluetooth devices can produce a more accurate location result than base station positioning. This technology also requires access to the network.
Location awareness is offered by the system as a basic service for applications. Depending on the service scenario, an application needs to initiate a location request to the system and stop the location request when the service scenario ends. In this process, the system reports the location information to the application on a real-time basis.
Your application can use the location function only after the user has granted the permission and turned on the function. If the location function is off, the system will not provide the location service for any application.
Since the location information is considered sensitive, your application still needs to obtain the location access permission from the user even if the user has turned on the location function. The system will provide the location service for your application only after it has been granted the permission to access the device location information.
Before using basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain permission from the user.
The system provides the following location permissions:
If your application needs to access the device location information, it must first request required permissions.
Declare the required permissions in the application configuration file. For details, see Requesting User Authorization.
has.authorize({
scope: 'scope.userLocation',
success: () => {
has.getLocation({
type: 'wgs84',
success(res) {
const latitude = res.latitude;
const longitude = res.longitude;
const speed = res.speed;
const accuracy = res.accuracy;
},
});
}
});