启动谷歌地图应用程序所提供的位置和标记 [英] Starting Google Maps App with provided location and marker

查看:196
本文介绍了启动谷歌地图应用程序所提供的位置和标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的应用程序,我想启动谷歌地图应用程序用提供的位置和标记。该标志应表明,有一些东西在给定的位置。

From my app I would like to start the Google Maps App with a provided location and a marker. The marker should indicate, that there is something on that given location.

现在,我有以下的code,这与意图的谷歌地图应用程序使用提供的位置(51.49234,7.43045)开始。

For now, I have the following code, which starts with an Intent the Google Maps App with the provided location (51.49234, 7.43045).

startActivity(
new Intent(
    android.content.Intent.ACTION_VIEW, 
    Uri.parse("geo:51.49234,7.43045")));

在谷歌地图应用程序启动时,它看起来如下:

When the Google Maps App starts, it looks like the following:

没有标记显示。我想,这对谷歌地图应用程序将显示在该位置上,这是通过给定意向的标志。是否有任何隐藏的意图URI的,我可以用它来显示谷歌地图应用程序中的一个标志?

No marker is shown. I would like, that the Google Maps App would show a marker on that position, which is given through the Intent. Is there any "hidden" Intent URI's which I can use to show a marker within the Google Maps App?

在此先感谢。

@Rajiv M.指着我询问周围的给定位置的想法。

@Rajiv M. pointed me to the idea of querying the surroundings with the given location.

所以,解决的办法是:查询你的给定位置的周围与你指定的位置作为参数。该URI是这样的:

So, the solution is: Query the surroundings of your given location with your given location as the parameter. The URI looks like:

geo:51.49234,7.43045?q=51.49234,7.43045

谷歌地图将显示查询结果作为街道名称:

Google Maps will show the query-result as the street name:

样的黑客攻击,但它似乎运作良好。

Kind of a hack, but it seems to work well.

为什么你不应该使用0,0作为地图上的位置

geo:0,0?q=51.49234,7.43045

当您启动谷歌地图应用程序与提供的地图位置点0,0,谷歌地图应用程序将开始搜索您的当前设备位置。而这需要时间。在某些情况下,当没有提供GPS信号的,太多。在此之前的谷歌地图应用程序将开始搜索查询51.49234,7.43045。

When you start Google Maps App with the provided map location point 0,0 , Google Maps App will start searching for your current device position. And this takes time. In some cases, when GPS signal is not provided, way too much. Until then the Google Maps App will start searching for your query 51.49234,7.43045.

推荐答案

尝试使用相同的目的出发谷歌地图,但与格式的URI:

Try starting Google Maps using the same intent, but with a URI of the format:

geo:34.067214,-118.349332?q=410+Hauser+Boulevard,+Los+Angeles,+CA

即。地理:0,0 Q = +街道地址

i.e. geo:0,0?q=street+address

应用程序应该再实际显示的点在该地址。如果你没有足够的地址,您可能需要使用服务将其转化为一个地址,这个工作。

The application should then actually show a point at that address. If you do not have the address, you may have to use a service to translate it to an address for this to work.

-

另一种选择是嵌入在应用程序中的图形窗口和内添加标记。教您如何使用MapViews /标志物,在您的应用程序可以在<一个发现href="http://mobiforge.com/developing/story/using-google-maps-android">http://mobiforge.com/developing/story/using-google-maps-android.

The other option is to embed a MapView in your application and add a marker within that. A tutorial for using MapViews / Markers with-in your application can be found at http://mobiforge.com/developing/story/using-google-maps-android.

这篇关于启动谷歌地图应用程序所提供的位置和标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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