2011-11-11 51 views
0

來自Titanium示例的以下代碼在iPhone上正常工作,但在Android上不起作用。有人可以告訴我這是怎麼寫的,以便它可以在Android 2.3.3上運行?如果我註釋掉'Ti.Geolocation.getCurrentPosition'並且它是結束標記,則錯誤不會顯示。Appcelerator地理定位不適用於Android

if (!_bounty.captured) { 
    var captureButton = Ti.UI.createButton({ 
     title:L('capture'), 
     top:10, 
     height:30, 
     width:200 
    }); 
    captureButton.addEventListener('click', function() { 
     if (Ti.Geolocation.locationServicesEnabled) { 
      Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_BEST; 
      Ti.Geolocation.getCurrentPosition(function(e) { //*causes error on Android* 
       var lng = e.coords.longitude; 
       var lat = e.coords.latitude; 
       bh.db.bust(_bounty.id, lat, lng); 

       bh.net.bustFugitive(Ti.Platform.id, function(_data) { 
        Ti.UI.createAlertDialog({ 
         message:_data.message 
        }).show(); 

        //on android, give a bit of a delay before closing the window... 
        if (Ti.Platform.osname == 'android') { 
         setTimeout(function() { 
          win.close(); 
         },2000); 
        } 
        else { 
         win.close(); 
        } 
       }); 
      }); 
     } 
     else { 
      Ti.UI.createAlertDialog({ 
       title:L('geo_error'), 
       message:L('geo_error_details') 
      }).show(); 
     } 
    }); 
    win.add(captureButton); 
} 

任何幫助表示讚賞。

+0

什麼是錯誤消息?哪個Ti版本? –

+0

鈦版本1.7.5, 運行時錯誤: \t位置:android_asset/Resources/ui.js; \t消息:解析時太深的遞歸 – basheps

+0

聽起來像是Android的Ti bug。您是否嘗試過早期版本的Ti Mobile SDK以查看它是否有效? –

回答

-1

您必須使用Google API SDK才能使用Android上的地理位置

相關問題