2011-06-08 114 views
2

我在數據庫中創建了一個名爲UserJourneyLocation的表,它由列LocationID,緯度,經度構成。緯度和經度值存儲在sqlite數據庫中。我想要獲取這些緯度和經度值是有在SQLite數據庫並顯示在地圖上,繪製路線顯示起始位置和目的地location.Please幫我解決這個problem.Thanks藉助數據庫中保存的緯度和經度值繪製路線

+0

問題不清楚 - 你是否只有存儲的開始和結束,並需要一些東西爲你找到一條路徑?還是你有完整的路徑,只需要代碼來繪製你在地圖上的路徑? – 2011-06-08 06:57:11

+0

嗨@Kendall Helmstetter我有整個路徑,我只需要代碼在地圖上繪製路徑 – Rani 2011-06-08 07:13:23

回答

0

試試這個: -

NSString *urlstring=[NSString stringWithFormat:@"http://maps.google.com/?saddr=%f,%f&daddr=%f,%f",sourcelocation.latitude,sourcelocation.longitude,destinationlocation.latitude,destinationlocation.longitude]; 
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlstring]]; 

它會打開你的谷歌地圖與路線指出你的源位置和目標位置。它需要的參數是源和目標位置的緯度和經度。通過您獲取表單數據庫的緯度和經度值。

+0

請你能解釋我這個代碼 – Rani 2011-06-08 07:41:21

+0

@Rani看到我編輯的答案。 – Gypsa 2011-06-08 07:51:31

+0

@rani我很想知道你的問題是否得到解決。 – Gypsa 2011-06-08 08:03:45

0

下一個代碼的iOS 4.0+

CLLocationCoordinate2D points[2]; // how many points you have saved 


points[0] = CLLocationCoordinate2DMake(52.3, 9.7); // you can for loop initializing, i made it so for simplicity :) 

points[1] = CLLocationCoordinate2DMake(52.37, 9.74); 



MKPolyline* ret = [MKPolyline polylineWithCoordinates:points count:2]; 

然後你可以添加它作爲覆蓋你mapView