API: Return Device Location
Allows you to check the device's geolocation coordinates and placemark data.
Requirements
- Integration of our JavaScript API into your webpage
- Sample code to run within the app and download for integration into your own project is available here.
- Best practices for working with the JavaScript API are available here.
- App Settings
- Content > JavaScript API > Access JavaScript API = By Import
- Check Location Coordinates
- On JavaScript API Request Only - requests location data using the kp_Geolocation_requestLocation function.
- On App Launch & On JavaScript API Request - for a stationary kiosk, defining these variables once when the app is launched may be sufficient and will help prevent battery drain from regular location monitoring.
- Continuously & On JavaScript API Request - queries once a minute for new location data.
- iOS/iPadOS Permissions
- Location Services - more on enabling specific iOS/iPadOS permissions here
Triggers via API Functions
Check Location Coordinates
This function allows the app to request and return current location coordinates for the device.
Format | kp_Geolocation_requestLocation(callback); |
Parameters |
|
Callback format | callback(error, location); |
Callback return values |
|
Check Location Placemark
This function triggers a callback returning arrays with the location placemark information for the device, which represents Apple's best approximation of a full physical address for the device.
Note that Apple rate-limits requests to its geocoding endpoint for placemark data - they recommend only requesting new placemark information if you don't have a previous location, if the user has moved a meaningful distance from the previous location, such as 1000 meters, and if it's been 60 seconds since the last geocode request.
Format | kp_Identification_requestDeviceContextInfo(callback); |
Parameters | callback - [string] the name of the callback to be triggered after the function has been executed |
Callback format | callback(deviceInfo); |
Callback return values | deviceInfo - [array] containing the following:
|
Notifications via API Callbacks
On Location Update
This callback is triggered by the app when the location is updated through the app's 'Update Location Coordinates Automatically' setting, which must be set to 'Continuously' to trigger this on an ongoing basis or 'On App Launch' to trigger this once on app launch.
This callback does not return coordinate data directly, but instead can be defined in the head of your page to trigger one of the functions described above to return new location data.
Format | kp_LocationTracker_locationDidUpdate(); |
Sample Code
- This sample code relies on the JavaScript APIs built into Kiosk Pro and will not run successfully in other browsers or within our in-app help interface.
- To run sample code, set the app's homepage to kioskgroup.com/location-api
- To download a .zip of sample code, click here.
Change Log
- Added in version 1.0. Ability to check location coordinates on-demand added in version 9.2. Ability to return placemark data added and app-defined variables deprecated in version 10.0