I'm building an application on worklight 6.0 and I'm trying to implement geolocation.
The method WL.Device.Geo.acquirePosition
always returns
{"code":3,"message":"Position retrieval timed out."}
I followed these steps:
Placed this code in my javascript file:
function wlCommonInit() {
WL.Device.Geo.acquirePosition(positive, negative, {
timeout : 30000,
enableHighAccuracy: true,
maximumAge:15000
});
}
function positive(data) {
WL.Logger.debug("bbbbbbbbbbb2" + JSON.stringify(data));
}
function negativa(data) {
WL.Logger.debug("aaaaaaaaaaaa" + JSON.stringify(data));
}
add an android environment
add these two permissions in AndroidManifest.xml:
uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"
uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
run the app on a samsung s2 with wifi and gps on
Is there anything that I'm missing?
I would also add to the AndroidManifest.xml the following:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
And make sure this is there as well:
<uses-feature android:name="android.hardware.wifi" />
Did you try with a higher timeout value?