Google Maps URL Scheme不显示标记

 細亞米奇Mego_677 发布于 2022-12-08 19:31

我用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"]]; 

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

在此输入图像描述

如何显示标记?

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

     [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=35.6653,139.6959"]];
    

    2022-12-11 03:08 回答
  • 在这里,您可以使用标记打开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]]]];        }
    }
    }
    

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

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

    2022-12-11 03:12 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有