打开谷歌通过有意在Android的具体位置地图具体位置、地图、Android

2023-09-03 21:32:48 作者:心若不动ゝ风又奈何

我设计的,我想在地图上显示具体位置一个应用程序。 我是路过的字符串这已经是放在谷歌地图地址。 以下是我的意图 code ..

I'm designing one application in which I want to show specific location on Map. I'm passing String of address which is already placed on Google Map. Following is my Intent code..

String url = "http://maps.google.com/maps?daddr="+address;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,  Uri.parse(url));
startActivity(intent);

但它给我的谷歌地图获取方向。我知道为什么,因为我在网​​址使用 DADDR ,但我不知道用什么具体位置..Please告诉我用什么有..

But it gives me Google Map for getting direction. I know why that so, because I used daddr in url but I don't know what to use for specific location..Please tell me what to use there..

推荐答案

我没有测试过这一点,但你可以尝试:

I have not tested this but you could try :

第一种方法:

String uri = String.format(Locale.ENGLISH, "geo:%f,%f", latitude, longitude);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
context.startActivity(intent);

编辑: 这可能不是与谷歌地图合作7,0

This might not work with Google maps 7,0

因此​​你可以改变的URI:

hence you could change the uri to :

第二个选项:

String geoUri = "http://maps.google.com/maps?q=loc:" + lat + "," + lng + " (" + mTitle + ")";

其中, mTitle 是位置的名称。

第三个选项:

geo:0,0?q=my+street+address

第四个选项:

String map = "http://maps.google.co.in/maps?q=" + yourAddress;

希望的作品,并帮助:D ..

Hope that works and helps :D..