function onTemporalEvent(){
Position.enableLocationEvents(Position.LOCATION_ONE_SHOT, method(:onPosition));
}
function onPosition(info) {
var myLocation = info.position.toDegrees();
System.println("Latitude: " + myLocation[0]); // e.g. 38.856147
System.println("Longitude: " + myLocation[1]); // e.g -94.800953
}
if I instead modify onTemporalEvent to call a member function in a module, such as this:
function onTemporalEvent(){
var myCallback = new Lang.Method(MyModule, :myMethod);
Position.enableLocationEvents(Position.LOCATION_ONE_SHOT, myCallback);
}
... the code fails, but in a new way. Rather than not finding the symbol, it's exiting with a "Permission required" error, even if I do have the app permissions correctly set in manifest.xml.
For what it's worth: I'm creating a widget that is looking up data from an API in a very broad radius the user (1000-2000m), and deliver a limited amount of data based on this. Is there any other relatively bulletproof way to get a low-precision location fix - I'd honestly be fine with something that was +-100m or used the last known fix if acquiring a GPS fix took more than a few seconds.