2

我正在开发一个应用程序,它必须在“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];
4

1 回答 1

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 上。

试试这个,到目前为止。告诉我你看到了什么。

于 2012-10-08T11:07:15.587 回答