【问题标题】:how to add my location to google maps api如何将我的位置添加到谷歌地图 api
【发布时间】:2017-03-03 06:26:39
【问题描述】:

如何在android中添加源地址以打开带有源地址和目的地地址的谷歌地图?

我尝试了以下方法:

String map ="https://maps.google.com/maps?saddr=My+Location&daddr="+address;

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(map));
i.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
startActivity(i);

我在地图应用程序中收到“我的位置没有结果”的错误

我的要求是我想用我正在传递的用户当前位置和目的地地址打开谷歌地图应用程序。

【问题讨论】:

    标签: android google-maps android-intent android-maps


    【解决方案1】:

    你可以试试这个方法:

    String uri = String.format(Locale.ENGLISH, "geo:0,0?q=", "ahmedabad");
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
    startActivity(intent);
    

    【讨论】:

    • 我试过这个,但它不起作用。我想从地图中的字段设置为“你的位置”,因为我们进入 uber 和 ola 应用程序
    • Uri gmmIntentUri = Uri.parse("geo:0,0?q="+address); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps");开始活动(地图意图);地址是保存我的目标地址的字符串变量
    猜你喜欢
    • 2021-10-30
    • 1970-01-01
    • 2012-11-02
    • 2019-06-23
    • 1970-01-01
    • 2016-04-22
    • 1970-01-01
    • 1970-01-01
    • 2021-04-20
    相关资源
    最近更新 更多