cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Personas extracting Geocoordinates to include in simplified notification

former_member818918
Discoverer
0 Kudos

Peter Spielvogel announced in his blog on January 16, 2018 that it was possible to natively location services (GPS) by SAP Personas.

"If you choose to run the Slipstream Engine in the SAP Fiori Client, you gain access to supported native device capabilities, such as camera (for barcode scanning), GPS (location services), calendar, and contacts. You can set the security as needed to allow or block access to these native device capabilities."

How can I enable this functionality to setup these native device capabilities for Personas where we would like to log the gps in the long text of a notification as standard text, to extract it later to assess and upload this as part of the FLOC and its related location.

Another part of this is the time required to get more accurate, eg you see sometimes it takes a few seconds for the device to in crease accuracy from 100m to 2 or 3 m accuracy. How is this managed?

Please advice if there is a better way or functionality to use,

Kind regards,

Laurens

Accepted Solutions (0)

Answers (1)

Answers (1)

kmagons
Advisor
Advisor

Hi Laurens,

SAP Screen Personas client technically is an HTML5 web application and has no direct access to any native location service APIs. Either Cordova containers such as SAP Fiori client or HTML5 geolocation APIs can be used to read the location data and process it further in an SAP Screen Personas script. The chosen environment determines which API is used to retrieve the geocoordinates and what service configuration options are available to you.

Here's a quick example on how the HTML Geolocation API could be used

- Allow your browser to access the location services for your SAP Screen Personas flavor URL. Mind that the most browsers require HTTPS to be used for Geolocation API to work

- Create new SAP Screen Personas flavor for any classic application rendered in either SAP GUI for HTML or Slipstream Engine

- Assign a new onLoad script under the screen events

- Save & close the flavor editor and open the scripts editor

- Consider the following simple code for your onLoad script

/*globals navigator */ 

var sCoordinates, oCoordinates
if(!navigator || !navigator.geolocation){
    //The browser doesn't support geolocation
    return;
}
navigator.geolocation.getCurrentPosition( position => {
    oCoordinates = position.coords;
    sCoordinates = `Latitude: ${oCoordinates.latitude}, Longitude: ${oCoordinates.longitude}`;
    session.utils.alert(sCoordinates)
});

Here's the result

Hope, this helps

Best regards

Krists Magons