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 に答える