问题标签 [google-maps-android-api-2]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
22006 浏览

android - Android Google Maps v2 - 将对象添加到标记

我们如何在新的Google Maps Android API v2中将对象添加到标记?所以如果我们点击InfoWindow,我们可以对这个对象做点什么吗?

这会设置对象的位置、标题和片段。但是,如果我单击InfoWindow

0 投票
2 回答
4281 浏览

android - osmdroid, Maps API v2, and fragments

Ok. You'd think this would be relatively simple, but nope.

I am using Open street maps on my website, as the data is free to use, edit, and update - my project follows this mantra, and alongside googles API usage restrictions/saving data restrictions, google maps simply was not suitable for me.. at least on the web.

Given this I thought i'd follow suit with my android app, and so I setup osmdroid utilizing open street maps data.

I can have a nice map in my activity.. I also followed a tutorial, and it seemed to work at least such that I can have a map view in a fragment within a tabhost/viewpager. What i really want however (for tablets), is a list of establishments in a fragment on the left, and a map fragment on the right showing where these establishments are.

Simple enough i would have thought, but hours and hours of research suggest this is not possible unless you use some complex code and some deprecated methods..

So.. the fragment (containing a map view) loads and runs perfectly in a tabhost.. i can access methods within the fragment from my activity etc.. yet nothing to just simply have two fragments side by side.

Now.. I know google have just come out with their API v2.. I installed it and had a play.. not really knowing how osmdroid works, I thought i could update so I have MapFragment instead of SherlockFragment (I use ABS).. this then just threw up logcat errors asking for API keys etc.. and given that I dont want to use google map data, I assumed that I had gone wrong.

So.. could anyone advise on how I can get a list fragment, and a map fragment side by side using anything that is available on the market, but preferably utilizing Open source map data such that their are no usage restrictions.

I'm sure an overall overview of "what is available, and how it works" would be very much appreciated by loads of users.. so if anyone could advise it would be amazing !

0 投票
6 回答
5954 浏览

android - 谷歌地图代码中的 BadParcelableException

运行稍加修改的 Google 地图示例会引发BadParcelableExceptionGoogle 地图代码。该类LatLng是可打包的,但找不到。谷歌地图代码似乎试图解开未被它包裹的对象。什么情况下有问题?

...

0 投票
2 回答
16131 浏览

android - Google Maps Android V2 和 Direction API

我正在开发一个应用程序,我需要知道当前用户位置和兴趣点之间的路径。

我正在使用 android 2.3.3、google maps android v2 和 direction api。我的问题是我找到的所有代码都是针对旧版地图的,我也尝试调整代码但失败了。我尝试在 LatLng 中更改 GeoPoint(此新版本不支持)。问题是我无法显示路径,为此我创建了一条新的折线并将其添加到地图中。

我发布我的代码:

解析器:

XML解析器

JsonParser(解析google方向json)

路线(保存 json 信息)

部分:

我的 MainActivity(由于用户本地化,有 326 行代码,你可以在 google 开发者网站上找到它,所以我们可以假设有两个静态点 A 和 B,我想从 A 到 B):

每个建议都被很好地接受

0 投票
1 回答
885 浏览

android - Android Maps V2 API 中的地面叠加层大小错误

我正在地图上放置一个地面叠加层。使用以下代码,我可以定位位图:

当我尝试使位图越来越大时,当我从 58 米变为 59 米时,叠加层会跳跃并变得比地图上预期的更大。有谁知道这是一个错误还是我做错了什么?

0 投票
4 回答
3354 浏览

android - Android 地图 V2 崩溃

我今天的大项目是将我的应用程序迁移到新的 Google Maps API V2。但是,现在我遇到了一个错误,我似乎无法找到根本原因。

我的堆栈跟踪如下所示:

我的活动课程如下所示:

我的布局文件如下所示:

我的清单的相关部分如下所示:

我真的把我的头撞在墙上,所以任何帮助都将不胜感激。

0 投票
13 回答
194759 浏览

android - Android Google Maps v2 - 为 myLocation 设置缩放级别

是否可以使用新的 Google Maps API v2 更改 myLocation 的缩放级别?

如果您设置GoogleMap.setEnableMyLocation(true);,您会在地图上找到一个按钮来查找您的位置。

如果您单击它,那么地图会将您带到您的位置并将其放大到一定程度。我可以将此缩放更改为更少或更多吗?

0 投票
4 回答
21266 浏览

android - GooglePlayServicesUtil.getErrorDialog 为空

我正在使用 ACRA ( arca.ch ) 生成自动错误报告。

我刚刚使用 Google Maps Android API v2 发布了我的应用程序的新版本。我在尝试显示 GooglePlayServicesUtil.getErrorDialog 返回的对话框时收到 EEEPad 和 Transformer Pad 用户报告的错误。有谁知道为什么会发生这种情况?

以下是 acra 报告的相关代码和 Logcat:

调用此行时:

日志猫:

提前感谢您提供的任何帮助。

更新

谷歌尚未解决该问题,一旦我听到任何内容,我将更新此问题(请参阅 CommonsWare 对 Google Bug 报告链接的回答)。同时,如果您遇到此问题并且不希望您的应用程序崩溃,这就是我目前正在做的事情:

0 投票
2 回答
14605 浏览

android - 如何使用 Google Maps Android API v2 绘制动态线(路线)

我想知道使用 Google Maps API v2 在地图上绘制动态路线的最佳做法是什么。我想要一张能够在用户移动时延长路线的地图。使用折线和折线选项似乎有明显的解决方案。但是在实例化折线后,我找不到一种简单的方法来添加点。绘制折线是这样的:

但是在我将这条线传递给 GoogleMap 之后,我无法向它添加任何新点。就像是

不会向我的路线添加任何内容。

我可以添加完整的新折线。但是没有办法延长现有的吗?我想出了一种方法,获取折线的所有点,添加新点,然后将它们写回线:

但这对我来说似乎很麻烦。有任何想法吗?

0 投票
7 回答
31892 浏览

android - “IBitmapDescriptorFactory 未初始化”错误

我正在尝试在 Google Maps Android API v2 中获取带有自定义图标的标记。我刚刚更改了 Google 提供的示例之一。我在方法中添加.icon(BitmapDescriptorFactory.fromResource(R.drawable.arrow))到 RawMapViewDemoActivitysetUpMap().

但我总是收到“IBitmapDescriptorFactory 未初始化”。

BitmapDescriptorFactory它说:

在使用此类中的任何方法之前,您必须执行以下操作之一以确保已初始化此类:

  • 等待 GoogleMap 从您添加到应用程序的 MapFragment 或 MapView 中可用。您可以通过调用 getMap() 方法并检查返回的对象是否不为空来验证 GoogleMap 是否可用。

  • 调用 MapsInitializer.initialize(Context)。只要没有抛出 com.google.android.gms.common.GooglePlayServicesNotAvailableException GooglePlayServicesNotAvailableException,这个类就会被正确初始化。

我做了第一个,但仍然收到此错误。有什么建议么?