2011-04-18 53 views
13

目前,我這樣做是爲了「獲取路線」:當您打開Goog​​le地圖網址時,您如何默認行走路線?

NSString *googleMapsURLString; 
googleMapsURLString = [NSString stringWithFormat: 
     @"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f", 
          curLoc.latitude,  // Start 
          curLoc.longitude, 
          self.hotspot.coordinate.latitude, 
          self.hotspot.coordinate.longitude]; 

NSLog(@"Opening URL: %@",googleMapsURLString); 

NSURL *url = [NSURL URLWithString:googleMapsURLString]; 
[[UIApplication sharedApplication] openURL:url]; 

有誰知道,如果有一個參數,通過走,而不是默認爲駕駛路線嗎?

回答

15

只需添加

dirflg=w 

爲您的參數。

+0

它似乎沒有工作。 '開幕網址:http://maps.google.com/?mode = walking&saddr = 51.504303,-0.114187&daddr = 51.502859,-0.107943',它仍然給駕駛方向... – Robert 2011-04-18 09:32:26

+0

啊,好點,該參數僅用於json請求。我現在要改變我的答案。 – 2011-04-18 10:41:51

+0

太棒了,謝謝。 – Robert 2011-04-18 12:42:31

相關問題