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:
- Created a new worklight project
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?