Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 用浮点变量替换google maps API参数值_Ios_Google Maps - Fatal编程技术网

Ios 用浮点变量替换google maps API参数值

Ios 用浮点变量替换google maps API参数值,ios,google-maps,Ios,Google Maps,google maps API需要如下参数: NSString *urlString=@"http://maps.google.com/maps?saddr=43.2923,5.45427&daddr=43.4697,5.65427"; [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]]; float latStation=topStation.sstationLatit

google maps API需要如下参数:

NSString *urlString=@"http://maps.google.com/maps?saddr=43.2923,5.45427&daddr=43.4697,5.65427";
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];
     float latStation=topStation.sstationLatitude;
    float longStation=topStation.sstationLongitude;
NSString *urlString=@"http://maps.google.com/maps?saddr=43.2923,5.45427&daddr=latStation,longStation";
        [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];
在该示例中,我直接给出了经度/纬度的值,但当我尝试将其作为如下变量:

NSString *urlString=@"http://maps.google.com/maps?saddr=43.2923,5.45427&daddr=43.4697,5.65427";
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];
     float latStation=topStation.sstationLatitude;
    float longStation=topStation.sstationLongitude;
NSString *urlString=@"http://maps.google.com/maps?saddr=43.2923,5.45427&daddr=latStation,longStation";
        [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];

这不起作用,我该怎么办,请提前告诉我:)

您可以像这样使用
stringWithFormat:

NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=43.2923,5.45427&daddr=%f,%f",latStation,longStation];

您可能想看一看。

thx很多,顺便问一下,既然我们谈到了谷歌地图,您知道在url中输入什么参数来请求谷歌API提供
轮流
功能吗?也许这可以帮助您:。