内存溢出异常 - 谷歌地图的GroundOverlay [英] Out of Memory Exception - Google Map GroundOverLay

查看:621
本文介绍了内存溢出异常 - 谷歌地图的GroundOverlay的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想绘制谷歌地图上的图片。我使用了最新版本的谷歌的播放服务,并查了很多关于这个问题,并不能找到答案。

I'm trying to draw a picture on the google map. I'm using the latest version of google play services and checked a lot for this issue and couldn't find an answer.

下面是一些code:

    BitmapDescriptor image = BitmapDescriptorFactory.fromResource(R.drawable.drawing_bg);
    LatLngBounds drawingBounds = new LatLngBounds(
                                   new LatLng(29.93530, 30.88324), 
                                   new LatLng(29.93609, 30.88329))
                                .including(new LatLng(29.93580, 30.88286))
                                .including(new LatLng(29.93563, 30.88374))
                                .including( new LatLng(29.93593, 30.88347))
                                .including(new LatLng(29.93561, 30.88298))
                                .including(new LatLng(29.93591, 30.88344))
                                .including(new LatLng(29.93563, 30.88301));
    GroundOverlay groundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions()
     .image(image)
     .zIndex(2)

     .positionFromBounds(drawingBounds)
     .transparency((float) 0.0));

    final Marker currentLocationMarker = mMap.addMarker(new MarkerOptions().position(new LatLng(29.93530, 30.88324)).draggable(true));
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(29.935431502437588,30.88327579200268), 20));

从LogCat中:

    05-03 11:45:17.860: E/dalvikvm-heap(1115): Out of memory on a 67108880-byte allocation.
    05-03 11:45:17.860: I/dalvikvm(1115): "GLThread 8598" prio=5 tid=21 RUNNABLE
    05-03 11:45:17.860: I/dalvikvm(1115):   | group="main" sCount=0 dsCount=0 obj=0x4284d580 self=0x5a559790
    05-03 11:45:17.860: I/dalvikvm(1115):   | sysTid=1502 nice=1 sched=0/0 cgrp=apps handle=1596223616
    05-03 11:45:17.860: I/dalvikvm(1115):   | schedstat=( 216011094 92043700 221 ) utm=19 stm=2 core=3
    05-03 11:45:17.860: I/dalvikvm(1115):   at android.graphics.Bitmap.nativeCreate(Native Method)
    05-03 11:45:17.860: I/dalvikvm(1115):   at android.graphics.Bitmap.createBitmap(Bitmap.java:640)
    05-03 11:45:17.860: I/dalvikvm(1115):   at android.graphics.Bitmap.createBitmap(Bitmap.java:620)
    05-03 11:45:17.860: I/dalvikvm(1115):   at maps.s.h.a((null):-1)
    05-03 11:45:17.860: I/dalvikvm(1115):   at maps.cr.a.a((null):-1)
    05-03 11:45:17.860: I/dalvikvm(1115):   at maps.cr.a.a((null):-1)
    05-03 11:45:17.860: I/dalvikvm(1115):   at maps.z.aa.b((null):-1)
    05-03 11:45:17.860: I/dalvikvm(1115):   at maps.z.aa.a((null):-1)
    05-03 11:45:17.860: I/dalvikvm(1115):   at maps.z.bi.a((null):-1)
    05-03 11:45:17.860: I/dalvikvm(1115):   at maps.af.v.a((null):-1)
    05-03 11:45:17.860: I/dalvikvm(1115):   at maps.af.v.a((null):-1)
    05-03 11:45:17.860: I/dalvikvm(1115):   at maps.af.v.a((null):-1)
    05-03 11:45:17.860: I/dalvikvm(1115):   at maps.p.q.m((null):-1)
    05-03 11:45:17.860: I/dalvikvm(1115):   at maps.p.q.run((null):-1)
    05-03 11:45:17.875: W/dalvikvm(1115): threadid=21: thread exiting with uncaught exception (group=0x412cc2a0)
    05-03 11:45:17.880: E/AndroidRuntime(1115): FATAL EXCEPTION: GLThread 8598
    05-03 11:45:17.880: E/AndroidRuntime(1115): java.lang.OutOfMemoryError
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at android.graphics.Bitmap.nativeCreate(Native Method)
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at android.graphics.Bitmap.createBitmap(Bitmap.java:640)
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at         android.graphics.Bitmap.createBitmap(Bitmap.java:620)
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at maps.s.h.a(Unknown Source)
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at maps.cr.a.a(Unknown Source)
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at maps.cr.a.a(Unknown Source)
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at maps.z.aa.b(Unknown Source)
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at maps.z.aa.a(Unknown Source)
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at maps.z.bi.a(Unknown Source)
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at maps.af.v.a(Unknown Source)
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at maps.af.v.a(Unknown Source)
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at maps.af.v.a(Unknown Source)
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at maps.p.q.m(Unknown Source)
    05-03 11:45:17.880: E/AndroidRuntime(1115):     at maps.p.q.run(Unknown Source)
    05-03 11:45:29.395: W/SurfaceView(1115): CHECK surface infomation creating=false formatChanged=false sizeChanged=false visible=false visibleChanged=true surfaceChanged=true realSizeChanged=false redrawNeeded=false left=false top=false

我真的AP preciate任何帮助

I would really appreciate any help

推荐答案

您不应该使用太大的图像。你logcat的建议你尝试分配67 MB,这是太多了大部分的设备。

You should not be using images that are too large. You logcat suggests you try to allocate 67 MB, which is way too much for most of the devices.

编辑:

也许尝试使用 TileOverlay 而不是的GroundOverlay 如果你想显示在大面积的图像(城市,国家),并没有放大时像素化。

Maybe try using TileOverlay instead of GroundOverlay if you want to show images on a large area (city, country) and not have it pixelated when zoomed.

这篇关于内存溢出异常 - 谷歌地图的GroundOverlay的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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