- This topic has 4 replies, 2 voices, and was last updated 10 years, 9 months ago by Lofi.
-
AuthorPosts
-
LofiParticipantThe geolocation check works on the web simulator, but not on the phone when I build my app via the Genuitec cloud service:
Both
alert("navigator.geolocation: " + JSON.stringify( navigator.geolocation));
and
alert("window.navigator.geolocation: " + JSON.stringify( window.navigator.geolocation));
return
{}
ie an empty string. So the check for the geolocation object succeeds, but I don’t get any data at all. I ask for all permissions on the phone for testing purposes, just to be on the safe side.
support-octavioMemberHi Lofi,
Could you share your device details: model and OS? Also your MyEclipse version.
A sample project would be very helpful to replicate the problem faster.
LofiParticipantHello Octavio,
thank you for the reply. MyEclipse 2014 Pro and Samsung Galaxy. I finally figured it out, found the info on some website. This code works:
var options = { timeout: 31000, enableHighAccuracy: true, maximumAge: 90000 }; navigator.geolocation.getCurrentPosition(onSuccess, onError, options);
What I was missing was the options. Without the options the getCurrentPosition method didn’t return anything on my Samsung Galaxy.
To be honest, if MyEclipse includes cordova.js and rte.js (what’s that used for?) it would have been really very helpful if there were sample code which uses the features.
support-octavioMemberHi Lofi,
Thanks for sharing your solution. I am curious to know if you determined the 31 sec timeout by trial and error? For example we typically see a success location returned in around 10 seconds if not sooner.
We also appreciate your feedback and as I said in the other thread, we will be providing more cordova/phonegap examples as we get closer to the next release.
LofiParticipantHello Octavio,
the 31 sec timeout is just random. Got the necessary info from here:
The important part: Only when I specify these options (with whatever timeout), then I see the GPS icon blink on the top left corner, i.e. the phone is searching for a GPS signal. Without the options there’s no searching and I’m left with an empty geolocation result.
The time I get a signal depends on whether I’m indoors or not, the weather, etc. The usual stuff. Sometimes I have to wait for a minute.
-
AuthorPosts