Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note

The getLocation query returns the device location coordinates, in the form of a javascript object with "longitude" and "latitude" properties. This will not work properly if the user does not grant the app access to the device's location services. An optional parameter may be used to request one of the following levels of accuracy: Fine, Medium, Coarse. If no value is specified, Medium will used as the default. Retrieving location may also be a slow process. Consider tuning pulsar.location.updateFrequencySeconds Pulsar Setting to adjust the trade off between accuracy and speed.

Code Block
var request = {
    "type" : "getLocation",
    "data" : { "locationAccuracy" : "Fine" }
};
 
bridge.sendRequest(request, function (results) {
    console.log('Javascript got its response: ' + results);
    if (results.type === "getLocationResponse") {
        var coord = results.data;
        alert('This device is at longitude: ' + coord.longitude + ' latitude: ' + coord.latitude + '. Accuracy level used was: ' + coord.locationAccuracy);
 
    } else if (results.type == 'error') {
         errStr = results.data;
         alert('A problem occurred:\n' + errStr);
    }
});

...