简体   繁体   English

在Android的Google地图中显示位置

[英]Show Location in Google Maps in Android

I want to start Google Maps and show the Location that are saved in String 's 我想启动Google Maps并显示保存在String的位置中

String street = projectItems.get(position).get(project_company_street);
String zip = projectItems.get(position).get(project_company_zip);
String city = projectItems.get(position).get(project_company_city);

I made something that doesn't meets my conditions. 我做的东西不符合我的条件。

Uri IntentUri = Uri.parse("google.navigation:q=" + street + "," + zip + "+" + city);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, IntentUri);

So if User presses the Button, Google Maps starts in Navigation Mode. 因此,如果用户按下按钮,则Google Maps将以导航模式启动。

How can I just show the Location of it? 我怎样才能显示它的位置?

Hope my problem is clear. 希望我的问题很清楚。

Kind Regards! 亲切的问候!

尝试将您的Uri更改为此:

Uri IntentUri = Uri.parse("geo:0,0?q=" + street + "," + zip + "+" + city);

You can achieve this by providing latitude and longitude of both current and destination locations like below 您可以通过提供当前位置和目标位置的纬度和经度来实现此目标,如下所示

String sAddr = "http://maps.google.com/maps?saddr=%s,%s&daddr=%s,%s";
String sAddr2 = String.format(sAddr, cur_lat, cur_long, dest_lat, dest_long);
Uri gmmIntentUri = Uri.parse(sAddr2);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivityForResult(mapIntent, GoTo_MAP);

Please check below example : 请检查以下示例:

 Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia&mode=b");
 Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
 mapIntent.setPackage("com.google.android.apps.maps");
 startActivity(mapIntent);

Ref : Google Navigation intent 参考: Google导航意图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM