2012-10-12 54 views
4

我想在Android應用程序中使用Google Transit API。但我從服務中獲取數據。我用下面的參數:在Android中使用Google Transit APIs

http://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&sensor=false&departure_time=1343605500&mode=transit

我總是得到這樣的迴應:

{ 
    "routes" : [], 
    "status" : "ZERO_RESULTS" 
} 

我想我傳遞一些錯誤在任何的上面URL中使用的參數,也許departure_time是錯了嗎?

任何人都可以告訴什麼應該傳遞給參數?
任何人都可以幫助我找出具有返回值的參數的URL嗎?

回答

3

你只需要將departure_time參數設置爲將來的某個時間(如幾天)。從here

當請求公交路線時,一定要指定一個 DEPARTURE_TIME或ARRIVAL_TIME。請注意,在本例中, 起飛時間指定爲2012年7月30日上午09:45。在提交請求之前將 參數更新爲將來的某個點。

嘗試http://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&sensor=false&departure_time=1350472557&mode=transit,它的工作原理。

+0

你是怎麼計算時間的 - 「1350472557」?什麼是實際時間? –

+0

這是[Unix時間](http://en.wikipedia.org/wiki/Unix_time)。有很多在線轉換器。 –

相關問題