我正在开发一个应用程序,它必须在地点“a - b”之间给出一个方向,而我在我的 UIWebView 中没有得到我想要的方向...可以帮助我一些人?
[self setDestinationLocation :@"an Address"];
[self setSourceLocation :@"53.219091,6.568096"];
int startMatch = 1;
int numberOfMatches=1;
[self setUrlAddress:
[NSString stringWithFormat:@"http://maps.google.com/maps?f=d&om=2&daddr=%@&saddr=%@&start=%d&num=%d&view=map&layer=t&t=m",
[self sourceLocation],
[self destinationLocation],
startMatch,
numberOfMatches
]
];
NSURL *url = [NSURL URLWithString:[self urlAddress]];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[[self webView] loadRequest:requestObj];
答案 0 :(得分:1)
试试这个简短的例子:
- (void)getDirections {
CLLocationCoordinate2D start = { (startLat), (startLong) };
CLLocationCoordinate2D end = { (EndLat), (EndLong) };
NSString *googleMapsURLString = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%f,%f&daddr=%f,%f", start.latitude, start.longitude, end.latitude, end.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]];
}
传递您想要的纬度,经度对。您有格式化的URL,将其显示在UIWebView上。
尝试这一点,截至目前。告诉我你所看到的。