appMobi watchPosition和getCurrentPosition失败了,我的小GPS图标出现并继续进行,但是从appmobi站点复制和粘贴它们的例子,我至少应该得到一个警告,如果不是,那么调试器的控制台出现错误,而我没有收到任何警告。
var options = {timeout: 10000, maximumAge: 11000, enableHighAccuracy: true };
//This function is called on every iteration of the watch Position command that fails
var fail = function(){
alert("Geolocation failed. \nPlease enable GPS in Settings.");
};
//This function is called on every iteration of the watchPosition command that is a success
var suc = function(p){
alert("Moved To: Latitude:" + p.coords.latitude + "Longitude: " + p.coords.longitude;
};
//This command starts watching the geolocation
var geolocationWatchTimer = AppMobi.geolocation.watchPosition(suc,fail,options);
//Call the stopGeolocation function to stop the geolocation watch
var stopGeolocation = function(){
AppMobi.geolocation.clearWatch(geolocationWatchTimer);
}.
更新
好的,注意到了,即使用那里的例子,代码也被破坏到了一定程度。它缺少了a)和a;因此,有了这些输入,我现在得到了Uncaught TypeError: Cannot call method 'watchPosition' of undefined。
好的,再次更新
修正了最后一个问题,但是这个问题让我很为难,好像它跑了两次是为了现在停下来,我需要它只运行一次。我怎么能拿到呢?
发布于 2013-01-29 01:10:22
放一个旗子只运行一次。
...lat=0;
var suc = function(p){
if ((p.coords.latitude != undefined)&&(lat==0))
{
console.log(p.coords.latitude);
lat=p.coords.latitude;..。
https://stackoverflow.com/questions/11490605
复制相似问题