Thursday, January 23, 2014

phonegap call gps geographic position of the interface, there are people successful call ah, why I did not test any of it to return information on the phone, find the Great God


            
phonegap call location interfaces, there are people successful call over ah. navigator.geolocation.getCurrentPosition (getPositionSuccess, getPositionError)
I measured this interface in the mobile phone, why not return the callback function does nothing, and even failure messages are not returned, and still others know why ah? Here is what I wrote js code:

/ / Get the callback function to be called when the location information
successfunction onSuccess (position) {
alert (position.coords.latitude);
}

/ / OnError callback function receives a PositionError object
function onError (error) {
alert ('code:' + error.code + '\ n' + 'message:' + error.message + '\ n');
}

$ ("# Position"). Click (function () {
if (navigator.geolocation) {
alert ('browser supports geolocation');
} Else {
alert ('browser does not support geolocation');
}
navigator.geolocation.getCurrentPosition (onSuccess, onError);
alert (11);
});
Reply:
What a coincidence, I just have encountered this problem, hit N Jiubu know why.
Reply:
Brothers, find the reasons.

http://stackoverflow.com/questions/7518468/phonegap-gps-without-internet

Look at phonegap official documents:

http://docs.phonegap.com/en/1.8.1/cordova_geolocation_geolocation.md.html # geolocationOptions

The bottom does have this description.

So, as long as
navigator.geolocation.getCurrentPosition (onSuccess, onError);
Changed
navigator.geolocation.getCurrentPosition (onSuccess, onError, {maximumAge: 3000, timeout: 5000, enableHighAccuracy: true});
On the line,

If there are errors, it will prompt an error.
Reply:
Thank dryZeng brothers, plus HighAccuracy: the true attributes reaction, but I am here and there is a problem that does not return the latitude and longitude information call interface, but the phone is set to see the gps running (this was previously not available) , if you set the timeout, then, to the ultra-specified time to see, it will error: Timeout reported. I do not know whether you have a case of brothers
Reply:
I set the timeout is 20 seconds,

Because Star Search is indeed very time-consuming thing.

I have set up long after the timeout, you can get the latitude and longitude of.

But also a time out in the room, because it does not search star.
Reply:
Hey, I do not for one minute out of the tragedy ah.
Reply:
I still can not use
Reply:
Why do I still timeout expired
appearThere would like to ask the simulator can do
Reply:
In the browser to return to the coordinates above
But the real machine appeared at the last location provider was disabled
Reply:
I'm doing a spot problems encountered location information can help me find perhaps you've encountered add me: 1364752683 Thank you
Reply:
Here is an example of open source, can be downloaded free without any limitations, you want a little help.
http://dev.10086.cn/ude/template-detail-49.do

No comments:

Post a Comment