打开谷歌通过有意在Android的具体位置地图 [英] open google maps through intent for specific location in android

查看:115
本文介绍了打开谷歌通过有意在Android的具体位置地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这篇关于打开谷歌通过有意在Android的具体位置地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆