簡體   English   中英

iPhone應用程序:使用地圖顯示方向

[英]iPhone App :show direction using Map

在我的iPhone應用程序中,如何顯示從當前位置到終點的路線?

iPhone上是否有任何可用的內置組件或設施,可以使用GPS和內置指南針顯示地圖和方向?

如果您要基於兩點將用戶帶到地圖應用程序,則可以這樣做:

  1. 創建如下所示的NSURL: NSURL *URL = [NSURL URLWithString:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f"]; 您可以正確插入起始地址和目的地(經緯度)。
  2. 告訴您的應用程序打開URL [[UIApplication sharedApplication] openURL:URL];

它應該帶您自動進入地圖應用程序!

嘗試這個:-

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]];
NSString *Urlstring=[NSString stringWithFormat:@"http://maps.google.com/?saddr=%@&daddr=%@",from_address,to_address];

[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlstring]];

這將為提及源地址和目標地址提供明確的指導。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM