Google Maps URL Scheme不显示标记

Nhu*_*yen 6 google-maps objective-c ios

我用iOS Google Maps URL Scheme打开Google Map应用程序,我有schema:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"comgooglemaps://?center=35.6653,139.6959&zoom=16&views=traffic&mapmode=standard"]]; 
Run Code Online (Sandbox Code Playgroud)

但是当我运行应用程序时,结果不会在位置显示标记(35.6653,139.6959).

在此输入图像描述

如何显示标记?

小智 12

你可以像在网址中传递纬度和经度一样显示标记

 [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=35.6653,139.6959"]];
Run Code Online (Sandbox Code Playgroud)


Kas*_*sas 6

在这里,您可以使用标记打开Goog​​le地图网站或Google地图应用.

- (void) onPositionPressed:(UITapGestureRecognizer*)sender{
NSNumber * latitude = [sender.view associativeObjectForKey:@"latitude"];
NSNumber * longitude = [sender.view associativeObjectForKey:@"longitude"];

if(latitude && longitude){
    //Abrimos Google Maps...
    if ([[UIApplication sharedApplication] canOpenURL:
         [NSURL URLWithString:@"comgooglemaps://"]]) {
        [[UIApplication sharedApplication] openURL:
         [NSURL URLWithString:[NSString stringWithFormat:@"comgooglemaps://?q=%.6f,%.6f&center=%.6f,%.6f&zoom=15&views=traffic", [latitude doubleValue], [longitude doubleValue], [latitude doubleValue], [longitude doubleValue]]]];
    } else {
        [[UIApplication sharedApplication] openURL:
         [NSURL URLWithString:[NSString stringWithFormat:@"https://maps.google.com/maps?&z=15&q=%.6f+%.6f&ll=%.6f+%.6f", [latitude doubleValue], [longitude doubleValue], [latitude doubleValue], [longitude doubleValue]]]];        }
}
}
Run Code Online (Sandbox Code Playgroud)

在这些情况下,纬度和经度是NSNumbers,但你可以使用普通的双变量.

我希望这有助于任何人;)


Nik*_* M. 0

突然之间,无法使用 Google 地图的 URL 方案显示标记。您只需传递一个参数即可显示从当前位置出发的路线。以下是该方案支持的所有参数的列表。