谷歌API的MapView内存不足的MapView设置为特定的宽度和高度后, [英] Google API MapView OutOfMemory after setting the MapView to specific width and height

查看:112
本文介绍了谷歌API的MapView内存不足的MapView设置为特定的宽度和高度后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索对于这个问题,我发现差不多的,但没有任何想法如何解决这个问题的一些计算器的问题。

i searched for this Problem, and i found some stackoverflow Questions about the same but without any idea how to resolve the problem.

我创建了一个活动,我想添加一个非常小的图形页面(如140瓦特点¯x70H)。这是只显示所放的地方是一个小preVIEW。当你点击这个小图形页面,你得到一个新的膨胀与孔地图一个新的活动。

I created an activity and i want to add a really small mapview (like 140w X 70h). It is only to show a small preview of where the place is. When you click this little mapview you get a new inflate to a new activity with the hole map.

图形页面:

<com.google.android.maps.MapView android:id="@+id/mapview" 
                android:layout_width="140dip"
                android:layout_height="80dip"
                android:layout_below="@id/attributes"
                android:layout_alignParentRight="true"
                android:apiKey="****"
                android:paddingBottom="60dp"/>

LogCat中:

LogCat:

05-30 14:34:53.758: ERROR/dalvikvm(1608): Out of memory: Heap Size=4039KB,   Allocated=2768KB, Bitmap Size=625KB
05-30 14:34:53.758: DEBUG/AndroidRuntime(1608): Shutting down VM
05-30 14:34:53.758: WARN/dalvikvm(1608): threadid=1: thread exiting with uncaught exception (group=0x400259f8)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608): FATAL EXCEPTION: main
05-30 14:34:53.768: ERROR/AndroidRuntime(1608): java.lang.OutOfMemoryError
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at com.google.googlenav.map.Map.resize(Unknown Source)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at com.google.android.maps.MapView.onMeasure(MapView.java:554)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.view.View.measure(View.java:8172)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:578)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:362)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.view.View.measure(View.java:8172)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:989)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.widget.ScrollView.onMeasure(ScrollView.java:286)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.view.View.measure(View.java:8172)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:578)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:362)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.view.View.measure(View.java:8172)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3140)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.view.View.measure(View.java:8172)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3140)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.view.View.measure(View.java:8172)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.view.ViewRoot.performTraversals(ViewRoot.java:805)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1744)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.os.Looper.loop(Looper.java:144)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at android.app.ActivityThread.main(ActivityThread.java:4937)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at java.lang.reflect.Method.invokeNative(Native Method)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at java.lang.reflect.Method.invoke(Method.java:521)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-30 14:34:53.768: ERROR/AndroidRuntime(1608):     at dalvik.system.NativeStart.main(Native Method)

这是错误。当我使用FILL_PARENT它的工作原理,但我不想用一个FILL_PARENT MapView类。

this is the error. When i use fill_parent it works, but i dont want a mapview with fill_parent.

也许你们知道另一种方式来获得地图的图像上的电流(或给出)位置的preVIEW小的图像。
是不是有可能显示一个小图形页面?

Maybe you guys know another way to get a preview small image of the current (or given) position on the map as image. Isn't it possible to show a small mapview ?

感谢

推荐答案

如果你只是想显示没有交互的静态地图我推荐的静态地图API从谷歌。可以定义标志物,该中心的规模和一些标签和它返回可以一个ImageView的内部容易地显示所生成的图像。这样做的好处:你不必调用一个完整的图形页面只是一个小地图图像。内存或用户交互的开销。适合你的方案。

If you just want to show a static map without interaction I recommend the static map api from google. You can define markers, the center, the size and some labels and it returns a generated image that can be easily shown inside a ImageView. The benefit of this: You don't have to invoke a complete MapView for just a small map image. No overhead of memory or user interaction. Perfect for the scenario you have.

这篇关于谷歌API的MapView内存不足的MapView设置为特定的宽度和高度后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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